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

[SOLVED]How to iterate over Attributes

xDStickerxDSticker Member Posts: 16 Contributor II
edited November 2018 in Help
Hello RM-Team,

I tried to iterate over the attributes with the "loop attributes"-operator, but the "select attributes"-operator seems not to work well within a loop :(

It only work's on the first cycle, thats why I think its not my fault. Could you tell me if this is a bug, and maybe when you will fix it?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="generate_data" compatibility="5.3.008" expanded="true" height="60" name="Generate Data" width="90" x="179" y="30">
       <parameter key="number_examples" value="10"/>
     </operator>
     <operator activated="true" class="loop_attributes" compatibility="5.3.008" expanded="true" height="76" name="Loop Attributes" width="90" x="313" y="30">
       <process expanded="true">
         <operator activated="true" breakpoints="after" class="select_attributes" compatibility="5.3.008" expanded="true" height="76" name="Select Attributes" width="90" x="112" y="30">
           <parameter key="attribute_filter_type" value="single"/>
           <parameter key="attribute" value="%{loop_attribute}"/>
         </operator>
         <connect from_port="example set" to_op="Select Attributes" to_port="example set input"/>
         <connect from_op="Select Attributes" from_port="example set output" to_port="example set"/>
         <portSpacing port="source_example set" spacing="0"/>
         <portSpacing port="sink_example set" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
       </process>
     </operator>
     <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
     <connect from_op="Loop Attributes" from_port="example set" 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>
Put a breakpoint on the SAtt-operator and see the difference between the output at the first cycle and the other one's.

Best xDSticker

Answers

  • mdcmdc Member Posts: 58 Maven

    Connect the output of the Select Attribute operator to the RES output.

    Matthew
  • tennenrishintennenrishin Member Posts: 177 Contributor II
    Some of the loop operators (the ones with ports named "exa") behave differently from the rest. While other loop operators pass the same initial exampleset into each iteration, these loop operators pass the output "exa" from one iteration to the input "exa" of the next, in effect forming an iterated chain of the internal operators. The advantage of this (in most applications) is that you end up getting one exampleset at the loop operator's output, rather than a collection.

    Because of this "chaining" your process amounts to selecting att1 from {att1,att2,att3,att4,att5} and then selecting att2 from {att1}, which is why it doesn't work.

    You could usually just use the macro to work directly on the full exampleset without first selecting. But if you really want to select each attribute into a different exampleset you could do it like this
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.008">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
       <process expanded="true">
         <operator activated="true" class="generate_data" compatibility="5.3.008" expanded="true" height="60" name="Generate Data" width="90" x="179" y="30">
           <parameter key="number_examples" value="10"/>
         </operator>
         <operator activated="true" class="loop_attributes" compatibility="5.3.008" expanded="true" height="94" name="Loop Attributes" width="90" x="313" y="30">
           <process expanded="true">
             <operator activated="true" class="select_attributes" compatibility="5.3.008" expanded="true" height="76" name="Select Attributes" width="90" x="112" y="30">
               <parameter key="attribute_filter_type" value="single"/>
               <parameter key="attribute" value="%{loop_attribute}"/>
             </operator>
             <connect from_port="example set" to_op="Select Attributes" to_port="example set input"/>
             <connect from_op="Select Attributes" from_port="example set output" to_port="result 1"/>
             <connect from_op="Select Attributes" from_port="original" to_port="example set"/>
             <portSpacing port="source_example set" spacing="0"/>
             <portSpacing port="sink_example set" spacing="0"/>
             <portSpacing port="sink_result 1" spacing="0"/>
             <portSpacing port="sink_result 2" spacing="0"/>
           </process>
         </operator>
         <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
         <connect from_op="Loop Attributes" from_port="result 1" 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>
  • xDStickerxDSticker Member Posts: 16 Contributor II
    Thank you for your help, was not easy to see this :)
Sign In or Register to comment.