"infinite Loop and break"
xmarceks
New Altair Community Member
How can I model a infitity loop that breaks in a specific situation. A macro is set at value etc. stop=0
Tagged:
0
Answers
-
Tricky one! Unfortunately the "Loop until" operator is not capable of defining a condition based on a macro (I will create a ticket for this one). You can work around this by misusing the exception operators. Wrap your loop inside a "Handle Exception" operator, use "Loop" with MAX_INTEGER iterations and place a branch operator inside which will throw an exception on a particular macro value. See example process below:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.009">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.009" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="handle_exception" compatibility="5.3.009" expanded="true" height="76" name="Handle Exception" width="90" x="112" y="30">
<process expanded="true">
<operator activated="true" class="loop" compatibility="5.3.009" expanded="true" height="76" name="Loop" width="90" x="112" y="30">
<parameter key="set_iteration_macro" value="true"/>
<parameter key="iterations" value="2147483647"/>
<process expanded="true">
<operator activated="true" class="print_to_console" compatibility="5.3.009" expanded="true" height="76" name="Print to Console" width="90" x="112" y="30">
<parameter key="log_value" value="%{iteration}"/>
</operator>
<operator activated="true" class="branch" compatibility="5.3.009" expanded="true" height="76" name="Branch" width="90" x="407" y="30">
<parameter key="condition_type" value="expression"/>
<parameter key="condition_value" value="%{iteration}>10"/>
<process expanded="true">
<operator activated="true" class="throw_exception" compatibility="5.3.009" expanded="true" height="76" name="Throw Exception" width="90" x="168" y="30">
<parameter key="message" value="%{iteration} > 10"/>
</operator>
<connect from_port="condition" to_op="Throw Exception" to_port="through 1"/>
<connect from_op="Throw Exception" from_port="through 1" to_port="input 1"/>
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
<process expanded="true">
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
</operator>
<connect from_port="input 1" to_op="Print to Console" to_port="through 1"/>
<connect from_op="Print to Console" from_port="through 1" to_op="Branch" to_port="condition"/>
<connect from_op="Branch" from_port="input 1" 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>
<connect from_port="in 1" to_op="Loop" to_port="input 1"/>
<connect from_op="Loop" from_port="output 1" to_port="out 1"/>
<portSpacing port="source_in 1" spacing="0"/>
<portSpacing port="source_in 2" spacing="0"/>
<portSpacing port="sink_out 1" spacing="0"/>
<portSpacing port="sink_out 2" spacing="0"/>
</process>
<process expanded="true">
<connect from_port="in 1" to_port="out 1"/>
<portSpacing port="source_in 1" spacing="0"/>
<portSpacing port="source_in 2" spacing="0"/>
<portSpacing port="sink_out 1" spacing="0"/>
<portSpacing port="sink_out 2" spacing="0"/>
</process>
</operator>
<connect from_port="input 1" to_op="Handle Exception" to_port="in 1"/>
<connect from_op="Handle Exception" from_port="out 1" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>0 -
thanks, I`m trying it now. But it seems to work about 50 hours . Nevermind.
The next problem is that RM sometimes failed to build a decision tree. I loop over examples (170 000 times) and after a few examples I design a decision tree build model. Within this loop it builds it cca 1600 times (that`s ok), but after 150th a decision tree failed and the model look like a one leaf and so every examples is labeled with one label, however there are two.
Is there a way to detect this behaviour simply? Can RM compare two models?
I have tried the group models, but I don`t know how it is worked. Does it take an average of confidence?
thanks
0