<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Jose,<br>
    <br>
    The Exec actor has a waitForProcess parameter:<br>
     "If true, then actor will wait until subprocess completes. The
    default is a boolean of value true."<br>
    <br>
    Maybe try creating a subprocess that reads data and writes data, but
    does not exit.  I tried using "ping source.eecs.berkeley.edu" as the
    command with waitForProcess set to true but I did not get any
    output, which seems wrong.<br>
    <br>
    One tip here is to right click on the External Execution (aka Exec)
    actor and select "Listen to Actor".  This brings up a window that
    displays information about what the actor is doing.<br>
    <br>
    In general, the issue here is that it is difficult to know what
    constitutes a firing of the External Execution actor.  In your case,
    it sounds like somehow the Dakota process reads some data and then
    write some data.  How would downstream actors know when the Dakota
    actor is done writing data?<br>
    <br>
    I could see modifying the Exec actor so that it reads data from its
    input port, sends that data to the subprocess and then waits until
    it get a line of data back and sends the data to the output port. 
    The subprocess would not be terminated and would wait for fresh
    input.  This would require a little Java programming.<br>
    <br>
    In terms of interfacing to external programs, there are several
    ways.<br>
    <br>
    Kepler uses Ptolemy as its runtime execution engine and I'm more
    familiar with Ptolemy, so I'll discuss this from the Ptolemy
    viewpoint.<br>
    <br>
    Kepler has an interface to R.  I'm not that familiar with it, maybe
    try looking at the documentation.<br>
    <br>
    Kepler and Ptolemy have a JNI-based interface to Matlab that uses a
    Matlab C-based shared library to execute code.  Developing such an
    interface is fairly complex.  These days, rather than using JNI,
    most people use JNA, which is easier to use than JNI.<br>
    <br>
    Ptolemy includes BCVTB in $PTII/lbnl.  BCVTB uses sockets to connect
    to subprocesses.  There is a small C example there.<br>
    <br>
    We are working on implementing the Functional Mock-up Interface
    (FMI) in Ptolemy.  This work is not complete.  FMI is an emerging
    standard that is primarily for use with Modelica, but could be
    useful for situations like yours.<br>
    <br>
    The way to proceed would be to check the documentation and mailing
    lists for R, the Exec actor, Matlab and BCVTB.<br>
    <br>
    <div class="moz-cite-prefix">On 12/7/12 10:42 AM, Jose Borreguero
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAEee4gU7jE6=yNq=_iAoD9RT3w0MJMuongSEcXw1bxsvGWt=BA@mail.gmail.com"
      type="cite"><font color="#000099">Thanks for the reply!<br>
        <br>
        In your example workflow, it seems that kepler creates a new
        subprocess every time the loop is executed, because sed
        s/Foo/Bar exits after execution. Unfortunately,  I need the
        subprocess having ownership of the external actor to remain for
        all loop iterations. Every iteration it should receive the input
        and create an output, but the process should not die.<br>
        <br clear="all">
      </font>
      <div><span style="color:rgb(0,0,153)">Jose</span><br>
      </div>
      <br>
      <br>
      <div class="gmail_quote">On Fri, Dec 7, 2012 at 1:34 PM,
        Christopher Brooks <span dir="ltr"><<a
            moz-do-not-send="true" href="mailto:cxh@eecs.berkeley.edu"
            target="_blank">cxh@eecs.berkeley.edu</a>></span> wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> I'm not that familiar
            with Kepler's ExternalExecution actor, but it looks like it
            uses ptolemy.actor.lib.Exec.<br>
            <br>
            The Exec actor reads data from an input port, executes a
            subprocess and places the output on the output port.<br>
            <br>
            You would need p1 to pass parameters to Dakota in a format
            that Dakota would understand.<br>
            You would need to process the Dakota output into a format
            that your p3 process would understand.<br>
            <br>
            In Synchronous Dataflow, you would need to put a SampleDelay
            in the loop.<br>
            I've attached a XML file where the initial value of the
            SampleDelay is the string "Foo"<br>
            The output of the SampleDelay is connected to the input of
            the ExternalExecution actor.<br>
            The ExternalExecution actor executes the command<br>
            sed s/Foo/Bar/<br>
            During the first iteration, the value of the input is "Foo",
            so the ExternalExecution actor substitutes "Bar".<br>
            For the second and subsequent iterations, the output is
            "Bar".<br>
            <br>
            I'm not sure how Dakota take parameters.  Typically, these
            sorts of tools can take parameters via a file, via the
            command line or via an input.<br>
            You would need to write code that would take the value of
            Kepler parameters and generate Dakota parameters.<br>
            See the ExpressionReader, ExpressionWriter, Token To
            Expression and Expression To Token actors.<br>
            <br>
            _Christopher
            <div>
              <div class="h5"><br>
                <br>
                <br>
                <div>On 12/5/12 9:25 AM, Jose Borreguero wrote:<br>
                </div>
              </div>
            </div>
            <blockquote type="cite">
              <div>
                <div class="h5"><font color="#000099">Dear kepler users,<br>
                    <br>
                    Newbie to kepler and trying to figure out how to
                    embed a call to the Dakota optimization package
                    within a workflow. <br>
                    <br>
                    When I start the workflow, I spawn a new process
                    (process ID p1). Using the ExternalExecution actor
                    will create a new process for Dakota (p2). The
                    problem is that Dakota create i turn a new process
                    (p3) in order to evaluate the cost function for a
                    given set of values of the parameters to be
                    optimized. This cost function is a multi-step
                    calculation which I wanted to model as part of the
                    overall workflow. The problem is that the cost
                    function has process ID p3, but the workflow has
                    process ID p1. How can I connect all these different
                    processes in a single workflow? Is this possible?<br>
                    <br>
                    Below is a very simplified workflow. Because it is
                    an optimization process, there is a loop between
                    Dakota and CostFunction evaluations.<br>
                    <br>
InitParams(p1)----->ExternalActorDakota(p2)------>CompositeActorCostFunction(p3)---|<br>
                                                                   
                             
                    ^                                                                   
                                                          |<br>
                                                                        
                        
                    |_____________________________________________________|<br>
                    <br>
                    Any help is much appreciated<br clear="all">
                  </font>
                  <div><span style="color:rgb(0,0,153)">Jose</span><br>
                  </div>
                  <br>
                  <br>
                  <fieldset></fieldset>
                  <br>
                </div>
              </div>
              <pre>_______________________________________________
Kepler-users mailing list
<a moz-do-not-send="true" href="mailto:Kepler-users@kepler-project.org" target="_blank">Kepler-users@kepler-project.org</a>
<a moz-do-not-send="true" href="http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users" target="_blank">http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre>
              <span class="HOEnZb"><font color="#888888"> </font></span></blockquote>
            <span class="HOEnZb"><font color="#888888"> <br>
                <pre cols="72">-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: <a moz-do-not-send="true" href="tel:510.643.9841" value="+15106439841" target="_blank">510.643.9841</a>                                (Office: 545Q Cory)
home: (F-Tu) <a moz-do-not-send="true" href="tel:707.665.0131" value="+17076650131" target="_blank">707.665.0131</a> cell: <a moz-do-not-send="true" href="tel:707.332.0670" value="+17073320670" target="_blank">707.332.0670</a> </pre>
              </font></span></div>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670 </pre>
  </body>
</html>