"Macro variable to indicate generation?"

keith
keith New Altair Community Member
edited November 2024 in Community Q&A
When using EvolutionaryWeighting, I am using the option to write the intermediate best weights to a file each generation.  I'd like to keep track of how the best weights change throughout the process by writing each intermediate file to a different file name.  Is it possible to use a macro variable in the filename something like:  intermed_weights_%{generation}.wgt  to accomplish this? 

Answers

  • IngoRM
    IngoRM New Altair Community Member
    Hi Keith,

    yes, this is possible - although with a little effort by using the process log for accessing the generation. Here we go:

    <operator name="Root" class="Process" expanded="yes">
        <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
            <parameter key="target_function" value="sum"/>
        </operator>
        <operator name="EvolutionaryWeighting" class="EvolutionaryWeighting" expanded="yes">
            <parameter key="population_size" value="1"/>
            <parameter key="maximum_number_of_generations" value="100"/>
            <parameter key="save_intermediate_weights" value="true"/>
            <parameter key="intermediate_weights_file" value="intermed_weights_%{generation}.wgt"/>
            <operator name="StoreCurrentGenerationInMacro" class="OperatorChain" expanded="yes">
                <operator name="ProcessLog" class="ProcessLog">
                    <list key="log">
                      <parameter key="generation" value="operator.EvolutionaryWeighting.value.generation"/>
                    </list>
                </operator>
                <operator name="ProcessLog2ExampleSet" class="ProcessLog2ExampleSet">
                    <parameter key="log_name" value="ProcessLog"/>
                </operator>
                <operator name="DataMacroDefinition" class="DataMacroDefinition">
                    <parameter key="macro" value="generation"/>
                    <parameter key="macro_type" value="data_value"/>
                    <parameter key="attribute_name" value="generation"/>
                    <parameter key="example_index" value="1"/>
                </operator>
                <operator name="ClearProcessLog" class="ClearProcessLog">
                    <parameter key="log_name" value="ProcessLog"/>
                    <parameter key="delete_table" value="true"/>
                </operator>
                <operator name="IOConsumer" class="IOConsumer">
                    <parameter key="io_object" value="ExampleSet"/>
                    <parameter key="deletion_type" value="delete_one"/>
                </operator>
            </operator>
            <operator name="XValidation" class="XValidation" expanded="no">
                <parameter key="sampling_type" value="shuffled sampling"/>
                <operator name="NearestNeighbors" class="NearestNeighbors">
                    <parameter key="k" value="3"/>
                </operator>
                <operator name="OperatorChain" class="OperatorChain" expanded="yes">
                    <operator name="ModelApplier" class="ModelApplier">
                        <list key="application_parameters">
                        </list>
                    </operator>
                    <operator name="Performance" class="Performance">
                    </operator>
                </operator>
            </operator>
        </operator>
    </operator>

    I really like the macro stuff in combination with the ProcessLog since you can do really nice things with this  8)

    Cheers,
    Ingo

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.