🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to connect Process and Operator?

User: "prayerslayer"
New Altair Community Member
Updated by Jocelyn
Hello!

I'm very aware of the fact that it's not being welcomed to ask questions regarding the chaining of operators programatically. However, I need to do this for my thesis and hope that you'll kindly oversee it this time.

Everything works really well already, but I couldn't figure out how to connect the output of an operator to a result port of my process. Could anyone give me a hint? It's this part:

image

I tried to look for ports of the RootOperator, but there was no output:

System.out.println("looking for process ports");
for (String port : process.getRootOperator().getInputPorts().getPortNames())
System.out.println(port);
Am I able to add it anyway? Or somewhere else?

The actual problem I have is that after the process finished, I can't access the result (because there is none, I guess).
INFO: Process finished successfully after 3 s
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:570)
at java.util.ArrayList.get(ArrayList.java:348)
at com.rapidminer.operator.IOContainer.getElementAt(IOContainer.java:112)
at BackendTest.main(BackendTest.java:128)
At this line:
if (process_result.getElementAt(0) instanceof ExampleSet) { ... }
Thanks in advance!

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "Marco_Boeck"
    New Altair Community Member
    Hi,

    you may ask whatever you want to know - we just encourage others to use the GUI approach because it is much easier. However if there's a reason why you need to do it programatically, it is perfectly fine ;)

    I put together a quick example for you:

    This is the example process with an operator not connected to an output port.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.003">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.003" expanded="true" name="Process">
        <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="639" width="950">
          <operator activated="true" class="retrieve" compatibility="5.2.003" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
    </process>
    This line connects the operator referenced by its name to the first output port of the process:

    process.getOperator("Retrieve").getOutputPorts().getPortByName("output").connectTo(process.getRootOperator().getSubprocess(0).getInnerSinks().getPortByIndex(0));
    And in case you need a procedure for input ports as well, you can find it here.

    Regards,
    Marco
    User: "prayerslayer"
    New Altair Community Member
    OP
    Thanks a lot, works like a charm :)