The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
"Using Select with Loop Operator"
jeganathanvelu
Member Posts: 17 Contributor II
Hi,
I have used loop operator and the result set is ioo object collections [ one for each month in the data]. I want to select the last output data set and process further.
In the select operator i have to specify an index number to represent which object in the collection i have to pick.
can i some how identify how many objects are created by the loop operator and provide that as input to the Select operator index ??
Thanks Jegan
I have used loop operator and the result set is ioo object collections [ one for each month in the data]. I want to select the last output data set and process further.
In the select operator i have to specify an index number to represent which object in the collection i have to pick.
can i some how identify how many objects are created by the loop operator and provide that as input to the Select operator index ??
Thanks Jegan
Tagged:
0
Answers
you may use a macro for your loop operator. In the parameters tab you can enable "set iteration macro" and define a name for it. By default the macro value is incresed by one with every loop iteration. For the index in the select operator you specify %{macroname} and receive the highest index. Of course you may also specify the same value for the number of iterations in the loop and for the index. This can also be a macro, just have a look at "Set Macro" operator.
Cheers,
Helge
In this case I aggregated on the label value to get the distinct number of values. In your case you could replace this with month.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.0.008">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="6.0.008" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="generate_data" compatibility="6.0.008" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
<parameter key="target_function" value="multi classification"/>
<parameter key="number_of_attributes" value="2"/>
<parameter key="attributes_lower_bound" value="0.0"/>
</operator>
<operator activated="true" class="aggregate" compatibility="6.0.008" expanded="true" height="76" name="Aggregate" width="90" x="179" y="30">
<list key="aggregation_attributes"/>
<parameter key="group_by_attributes" value="label"/>
</operator>
<operator activated="true" class="extract_macro" compatibility="6.0.008" expanded="true" height="60" name="Extract Macro" width="90" x="313" y="30">
<parameter key="macro" value="NumExamples"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" class="loop" compatibility="6.0.008" expanded="true" height="76" name="Loop" width="90" x="179" y="120">
<parameter key="set_iteration_macro" value="true"/>
<parameter key="iterations" value="%{NumExamples}"/>
<process expanded="true">
<operator activated="true" class="generate_attributes" compatibility="6.0.008" expanded="true" height="76" name="Generate Attributes" width="90" x="246" y="30">
<list key="function_descriptions">
<parameter key="DummyAttribute_%{iteration}" value="%{iteration}"/>
</list>
</operator>
<connect from_port="input 1" to_op="Generate Attributes" to_port="example set input"/>
<connect from_op="Generate Attributes" from_port="example set output" to_port="output 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<operator activated="true" class="select" compatibility="6.0.008" expanded="true" height="60" name="Select" width="90" x="313" y="120">
<parameter key="index" value="%{NumExamples}"/>
</operator>
<connect from_op="Generate Data" from_port="output" to_op="Aggregate" to_port="example set input"/>
<connect from_op="Aggregate" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Aggregate" from_port="original" to_op="Loop" to_port="input 1"/>
<connect from_op="Loop" from_port="output 1" to_op="Select" to_port="collection"/>
<connect from_op="Select" from_port="selected" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>