Root operator output

zis
zis New Altair Community Member
edited November 5 in Community Q&A
Hi,

I have a process with nested operators (Loop Example). I have to get an output from root operator. Loop example is a last operator and in XML defenition is

<connect from_op="Loop Examples" from_port="output 1" to_port="result 1"/>
<connect from_op="Loop Examples" from_port="output 2" to_port="result 2"/>
in code I have

IOObject o1 = process.getRootOperator().getOutputPorts().getPortByName("result 1").getAnyDataOrNull(); // or getData()
IOObject o2 = process.getRootOperator().getOutputPorts().getPortByName("result 2").getAnyDataOrNull(); // or getData()
But it throws NullPointerException.

Complete process is defined below.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.014">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.1.014" expanded="true" name="rm-report1-p2">
   <parameter key="logverbosity" value="init"/>
   <parameter key="random_seed" value="2001"/>
   <parameter key="send_mail" value="never"/>
   <parameter key="notification_email" value=""/>
   <parameter key="process_duration_for_mail" value="30"/>
   <parameter key="encoding" value="SYSTEM"/>
   <parameter key="parallelize_main_process" value="false"/>
   <process expanded="true" height="645" width="1083">
     <operator activated="true" class="read_csv" compatibility="5.1.014" expanded="true" height="60" name="Read CSV" width="90" x="45" y="75">
       <parameter key="csv_file" value="C:\Users\Zis\Documents\NetBeansProjects\seage\seage-launcher\report\report.csv"/>
       <parameter key="column_separators" value=";"/>
       <parameter key="trim_lines" value="false"/>
       <parameter key="use_quotes" value="true"/>
       <parameter key="quotes_character" value="&quot;"/>
       <parameter key="escape_character_for_quotes" value="\"/>
       <parameter key="skip_comments" value="false"/>
       <parameter key="comment_characters" value="#"/>
       <parameter key="parse_numbers" value="true"/>
       <parameter key="decimal_character" value="."/>
       <parameter key="grouped_digits" value="false"/>
       <parameter key="grouping_character" value=","/>
       <parameter key="date_format" value=""/>
       <parameter key="first_row_as_names" value="false"/>
       <list key="annotations">
         <parameter key="0" value="Name"/>
       </list>
       <parameter key="time_zone" value="SYSTEM"/>
       <parameter key="locale" value="English (United States)"/>
       <parameter key="encoding" value="windows-1250"/>
       <list key="data_set_meta_data_information">
         <parameter key="0" value="ExperimentID.true.text.attribute"/>
         <parameter key="1" value="ProblemID.true.text.attribute"/>
         <parameter key="2" value="AlgorithmID.true.text.attribute"/>
         <parameter key="3" value="InstanceID.true.text.attribute"/>
         <parameter key="4" value="ConfigID.true.text.attribute"/>
         <parameter key="5" value="SolutionValue.true.real.attribute"/>
         <parameter key="6" value="Time.true.real.attribute"/>
         <parameter key="7" value="p1.true.real.attribute"/>
         <parameter key="8" value="p2.true.real.attribute"/>
         <parameter key="9" value="p3.true.real.attribute"/>
         <parameter key="10" value="p4.true.real.attribute"/>
         <parameter key="11" value="p5.true.real.attribute"/>
         <parameter key="12" value="p6.true.real.attribute"/>
         <parameter key="13" value="p7.true.real.attribute"/>
         <parameter key="14" value="p8.true.real.attribute"/>
         <parameter key="15" value="p9.true.real.attribute"/>
         <parameter key="16" value="p10.true.real.attribute"/>
         <parameter key="17" value="att18.false.attribute_value.attribute"/>
       </list>
       <parameter key="read_not_matching_values_as_missings" value="true"/>
       <parameter key="datamanagement" value="double_array"/>
     </operator>
     <operator activated="true" class="generate_attributes" compatibility="5.1.014" expanded="true" height="76" name="Generate Attributes" width="90" x="112" y="210">
       <list key="function_descriptions">
         <parameter key="id" value="concat(ExperimentID,&quot;-&quot;,ProblemID,&quot;-&quot;,AlgorithmID,&quot;-&quot;,InstanceID)"/>
       </list>
       <parameter key="use_standard_constants" value="true"/>
       <parameter key="keep_all" value="true"/>
     </operator>
     <operator activated="true" class="set_role" compatibility="5.1.014" expanded="true" height="76" name="Set Role" width="90" x="179" y="75">
       <parameter key="name" value="id"/>
       <parameter key="target_role" value="id"/>
       <list key="set_additional_roles"/>
     </operator>
     <operator activated="true" class="replace_missing_values" compatibility="5.1.014" expanded="true" height="94" name="Replace Missing Values" width="90" x="313" y="210">
       <parameter key="return_preprocessing_model" value="false"/>
       <parameter key="create_view" value="false"/>
       <parameter key="attribute_filter_type" value="subset"/>
       <parameter key="attribute" value=""/>
       <parameter key="attributes" value="|p9|p8|p7|p6|p5|p4|p3|p2|p10|p1"/>
       <parameter key="use_except_expression" value="false"/>
       <parameter key="value_type" value="attribute_value"/>
       <parameter key="use_value_type_exception" value="false"/>
       <parameter key="except_value_type" value="time"/>
       <parameter key="block_type" value="attribute_block"/>
       <parameter key="use_block_type_exception" value="false"/>
       <parameter key="except_block_type" value="value_matrix_row_start"/>
       <parameter key="invert_selection" value="false"/>
       <parameter key="include_special_attributes" value="false"/>
       <parameter key="default" value="value"/>
       <list key="columns"/>
       <parameter key="replenishment_value" value="-1"/>
     </operator>
     <operator activated="true" class="multiply" compatibility="5.1.014" expanded="true" height="76" name="Multiply" width="90" x="447" y="75"/>
     <operator activated="true" class="aggregate" compatibility="5.1.014" expanded="true" height="76" name="Aggregate" width="90" x="581" y="30">
       <parameter key="use_default_aggregation" value="false"/>
       <parameter key="attribute_filter_type" value="all"/>
       <parameter key="attribute" value=""/>
       <parameter key="attributes" value=""/>
       <parameter key="use_except_expression" value="false"/>
       <parameter key="value_type" value="attribute_value"/>
       <parameter key="use_value_type_exception" value="false"/>
       <parameter key="except_value_type" value="time"/>
       <parameter key="block_type" value="attribute_block"/>
       <parameter key="use_block_type_exception" value="false"/>
       <parameter key="except_block_type" value="value_matrix_row_start"/>
       <parameter key="invert_selection" value="false"/>
       <parameter key="include_special_attributes" value="false"/>
       <parameter key="default_aggregation_function" value="average"/>
       <list key="aggregation_attributes">
         <parameter key="SolutionValue" value="average"/>
         <parameter key="p1" value="minimum"/>
         <parameter key="p2" value="minimum"/>
         <parameter key="p3" value="minimum"/>
         <parameter key="p4" value="minimum"/>
         <parameter key="p5" value="minimum"/>
         <parameter key="p6" value="minimum"/>
         <parameter key="p7" value="minimum"/>
         <parameter key="p8" value="minimum"/>
         <parameter key="p9" value="minimum"/>
         <parameter key="p10" value="minimum"/>
       </list>
       <parameter key="group_by_attributes" value="id|AlgorithmID|ConfigID|ExperimentID|InstanceID|ProblemID"/>
       <parameter key="count_all_combinations" value="false"/>
       <parameter key="only_distinct" value="false"/>
       <parameter key="ignore_missings" value="true"/>
     </operator>
     <operator activated="true" class="store" compatibility="5.1.014" expanded="true" height="60" name="Store" width="90" x="849" y="30">
       <parameter key="repository_entry" value="//SEAGE/rm-report1-p3"/>
     </operator>
     <operator activated="true" class="aggregate" compatibility="5.1.014" expanded="true" height="76" name="Aggregate (2)" width="90" x="715" y="165">
       <parameter key="use_default_aggregation" value="false"/>
       <parameter key="attribute_filter_type" value="all"/>
       <parameter key="attribute" value=""/>
       <parameter key="attributes" value=""/>
       <parameter key="use_except_expression" value="false"/>
       <parameter key="value_type" value="attribute_value"/>
       <parameter key="use_value_type_exception" value="false"/>
       <parameter key="except_value_type" value="time"/>
       <parameter key="block_type" value="attribute_block"/>
       <parameter key="use_block_type_exception" value="false"/>
       <parameter key="except_block_type" value="value_matrix_row_start"/>
       <parameter key="invert_selection" value="false"/>
       <parameter key="include_special_attributes" value="false"/>
       <parameter key="default_aggregation_function" value="average"/>
       <list key="aggregation_attributes">
         <parameter key="id" value="count"/>
       </list>
       <parameter key="group_by_attributes" value="|id"/>
       <parameter key="count_all_combinations" value="false"/>
       <parameter key="only_distinct" value="false"/>
       <parameter key="ignore_missings" value="true"/>
     </operator>
     <operator activated="true" class="loop_examples" compatibility="5.1.014" expanded="true" height="112" name="Loop Examples" width="90" x="849" y="165">
       <parameter key="iteration_macro" value="example"/>
       <parameter key="parallelize_example_process" value="false"/>
       <process expanded="true" height="674" width="1094">
         <operator activated="true" class="retrieve" compatibility="5.1.014" expanded="true" height="60" name="Retrieve" width="90" x="45" y="210">
           <parameter key="repository_entry" value="//SEAGE/rm-report1-p3"/>
         </operator>
         <operator activated="true" class="set_role" compatibility="5.1.014" expanded="true" height="76" name="Set Role (3)" width="90" x="246" y="210">
           <parameter key="name" value="id"/>
           <parameter key="target_role" value="id"/>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="extract_macro" compatibility="5.1.014" expanded="true" height="60" name="Extract Macro" width="90" x="45" y="75">
           <parameter key="macro" value="val"/>
           <parameter key="macro_type" value="data_value"/>
           <parameter key="statistics" value="average"/>
           <parameter key="attribute_name" value="id"/>
           <parameter key="example_index" value="%{a}"/>
         </operator>
         <operator activated="true" class="filter_examples" compatibility="5.1.014" expanded="true" height="76" name="Filter Examples" width="90" x="179" y="75">
           <parameter key="condition_class" value="attribute_value_filter"/>
           <parameter key="parameter_string" value="id=%{val}"/>
           <parameter key="invert_filter" value="false"/>
         </operator>
         <operator activated="true" class="set_role" compatibility="5.1.014" expanded="true" height="76" name="Set Role (2)" width="90" x="313" y="75">
           <parameter key="name" value="id"/>
           <parameter key="target_role" value="id"/>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="intersect" compatibility="5.1.014" expanded="true" height="76" name="Intersect" width="90" x="447" y="165"/>
         <operator activated="true" class="sort" compatibility="5.1.014" expanded="true" height="76" name="Sort" width="90" x="581" y="165">
           <parameter key="attribute_name" value="average(SolutionValue)"/>
           <parameter key="sorting_direction" value="increasing"/>
         </operator>
         <operator activated="true" class="multiply" compatibility="5.1.014" expanded="true" height="94" name="Multiply (2)" width="90" x="782" y="120"/>
         <operator activated="true" class="aggregate" compatibility="5.1.014" expanded="true" height="76" name="Aggregate (3)" width="90" x="916" y="210">
           <parameter key="use_default_aggregation" value="false"/>
           <parameter key="attribute_filter_type" value="all"/>
           <parameter key="attribute" value=""/>
           <parameter key="attributes" value=""/>
           <parameter key="use_except_expression" value="false"/>
           <parameter key="value_type" value="attribute_value"/>
           <parameter key="use_value_type_exception" value="false"/>
           <parameter key="except_value_type" value="time"/>
           <parameter key="block_type" value="attribute_block"/>
           <parameter key="use_block_type_exception" value="false"/>
           <parameter key="except_block_type" value="value_matrix_row_start"/>
           <parameter key="invert_selection" value="false"/>
           <parameter key="include_special_attributes" value="false"/>
           <parameter key="default_aggregation_function" value="average"/>
           <list key="aggregation_attributes">
             <parameter key="minimum(p1)" value="average"/>
             <parameter key="minimum(p1)" value="standard_deviation"/>
             <parameter key="minimum(p2)" value="average"/>
             <parameter key="minimum(p2)" value="standard_deviation"/>
             <parameter key="minimum(p3)" value="average"/>
             <parameter key="minimum(p3)" value="standard_deviation"/>
           </list>
           <parameter key="group_by_attributes" value="|InstanceID"/>
           <parameter key="count_all_combinations" value="false"/>
           <parameter key="only_distinct" value="false"/>
           <parameter key="ignore_missings" value="true"/>
         </operator>
         <connect from_port="example set" to_op="Extract Macro" to_port="example set"/>
         <connect from_op="Retrieve" from_port="output" to_op="Set Role (3)" to_port="example set input"/>
         <connect from_op="Set Role (3)" from_port="example set output" to_op="Intersect" to_port="example set input"/>
         <connect from_op="Extract Macro" from_port="example set" to_op="Filter Examples" to_port="example set input"/>
         <connect from_op="Filter Examples" from_port="example set output" to_op="Set Role (2)" to_port="example set input"/>
         <connect from_op="Set Role (2)" from_port="example set output" to_op="Intersect" to_port="second"/>
         <connect from_op="Intersect" from_port="example set output" to_op="Sort" to_port="example set input"/>
         <connect from_op="Sort" from_port="example set output" to_op="Multiply (2)" to_port="input"/>
         <connect from_op="Multiply (2)" from_port="output 1" to_port="output 1"/>
         <connect from_op="Multiply (2)" from_port="output 2" to_op="Aggregate (3)" to_port="example set input"/>
         <connect from_op="Aggregate (3)" from_port="example set output" to_port="output 2"/>
         <portSpacing port="source_example set" spacing="0"/>
         <portSpacing port="sink_example set" spacing="0"/>
         <portSpacing port="sink_output 1" spacing="0"/>
         <portSpacing port="sink_output 2" spacing="0"/>
         <portSpacing port="sink_output 3" spacing="0"/>
       </process>
     </operator>
     <connect from_op="Read CSV" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
     <connect from_op="Generate Attributes" from_port="example set output" to_op="Set Role" to_port="example set input"/>
     <connect from_op="Set Role" from_port="example set output" to_op="Replace Missing Values" to_port="example set input"/>
     <connect from_op="Replace Missing Values" from_port="example set output" to_op="Multiply" to_port="input"/>
     <connect from_op="Multiply" from_port="output 1" to_op="Aggregate" to_port="example set input"/>
     <connect from_op="Aggregate" from_port="example set output" to_op="Store" to_port="input"/>
     <connect from_op="Aggregate" from_port="original" to_op="Aggregate (2)" to_port="example set input"/>
     <connect from_op="Aggregate (2)" from_port="example set output" to_op="Loop Examples" to_port="example set"/>
     <connect from_op="Loop Examples" from_port="output 1" to_port="result 1"/>
     <connect from_op="Loop Examples" from_port="output 2" to_port="result 2"/>
     <portSpacing port="source_input 1" spacing="0"/>
     <portSpacing port="sink_result 1" spacing="72"/>
     <portSpacing port="sink_result 2" spacing="0"/>
     <portSpacing port="sink_result 3" spacing="0"/>
   </process>
 </operator>
</process>
Thanks for ideas,
Regards,
Jonh

Answers

  • zis
    zis New Altair Community Member
    If I get data from last operator (Example Loop) from output ports output 1 and output 2, its working fine. But I want to get result 1 and result 2 from root process operator. Any idea?

    Regards,
    John
  • MariusHelf
    MariusHelf New Altair Community Member
    Hi John,

    the result ports are actually not ouput ports, but sinks of the inner process of the root operator. Something like this should work:
    process.getRootOperator().getSubprocess(0).getInnerSinks().getPortByIndex(0)
    Best, Marius