The plugin can be a C++ plugin implemented in a dynamic library (.so file) or a Python plugin implemented in a Python module (.py).
It is possible to implement two kinds of algorithm : synchronous or asynchronous.
+The algorithm uses a pool of samples to be evaluated.
+When all the samples of the pool are evaluated, the algorithm stops.
+
Synchronous algorithm
--------------------------------------------------
In synchronous mode, the OptimizerLoop calls the algorithm to know what are the types of the input port (sample sent to the internal node),
- **getTCForIn**, this method must return the YACS type of the input port of the internal node
- **getTCForOut**, this method must return the YACS type of the output port of the internal node
+- **getTCForAlgoInit** (optional), this method returns the type of the "algoInit" port, string if undefined
+- **getTCForAlgoResult** (optional), this method returns the type of the "algoResult" port, string if undefined
- **initialize** (optional), this method is called during the algorithm initialization
- **start**, this method is called at the beginning of iterations
- **takeDecision**, this method is called at each iteration
- **finish** (optional), this method is called to finish the algorithm at the end of the iteration process
+- **getAlgoResult** (optional), this method returns the value of the "algoResult" port, "NULL" if undefined
In Python you need to implement another method:
''''''''''''''''''''
Here is a small example of a C++ synchronous algorithm:
-.. code-block:: cpp
-
- #include <cmath>
-
- #include "OptimizerAlg.hxx"
-
- using namespace YACS::ENGINE;
-
- extern "C"
- {
- OptimizerAlgBase * createOptimizerAlgSyncExample(Pool * pool);
- }
-
- class OptimizerAlgSyncExample : public OptimizerAlgSync
- {
- private:
- int _idTest;
- TypeCode *_tcIn;
- TypeCode *_tcOut;
- public:
- OptimizerAlgSyncExample(Pool *pool);
- virtual ~OptimizerAlgSyncExample();
- TypeCode *getTCForIn() const;
- TypeCode *getTCForOut() const;
- void start();
- void takeDecision();
- void initialize(const Any *input) throw(YACS::Exception);
- void finish();
- };
-
- OptimizerAlgSyncExample::OptimizerAlgSyncExample(Pool *pool)
- : OptimizerAlgSync(pool), _tcIn(0), _tcOut(0), _idTest(0)
- {
- _tcIn=new TypeCode(Double);
- _tcOut=new TypeCode(Int);
- }
-
- OptimizerAlgSyncExample::~OptimizerAlgSyncExample()
- {
- _tcIn->decrRef();
- _tcOut->decrRef();
- }
-
- //! Return the typecode of the expected input type
- TypeCode * OptimizerAlgSyncExample::getTCForIn() const
- {
- return _tcIn;
- }
-
- //! Return the typecode of the expected output type
- TypeCode * OptimizerAlgSyncExample::getTCForOut() const
- {
- return _tcOut;
- }
-
- //! Start to fill the pool with samples to evaluate
- void OptimizerAlgSyncExample::start()
- {
- _idTest=0;
- Any *val=AtomAny::New(1.2);
- _pool->pushInSample(4,val);
- val=AtomAny::New(3.4);
- _pool->pushInSample(9,val);
- }
-
- //! This method is called each time a sample has been evaluated.
- /*!
- * It can either add new samples to evaluate in the pool, do nothing (wait
- * for more samples), or empty the pool to finish the evaluation.
- */
- void OptimizerAlgSyncExample::takeDecision()
- {
- if(_idTest==1)
- {
- Any *val=AtomAny::New(5.6);
- _pool->pushInSample(16,val);
- val=AtomAny::New(7.8);
- _pool->pushInSample(25,val);
- val=AtomAny::New(9. );
- _pool->pushInSample(36,val);
- val=AtomAny::New(12.3);
- _pool->pushInSample(49,val);
- }
- else if(_idTest==4)
- {
- Any *val=AtomAny::New(45.6);
- _pool->pushInSample(64,val);
- val=AtomAny::New(78.9);
- _pool->pushInSample(81,val);
- }
- else
- {
- Any *tmp= _pool->getCurrentInSample();
- if(fabs(tmp->getDoubleValue()-45.6)<1.e-12)
- _pool->destroyAll();
- }
- _idTest++;
- }
-
- //! Optional method to initialize the algorithm.
- /*!
- * For now, the parameter input is always NULL. It might be used in the
- * future to initialize an algorithm with custom data.
- */
- void OptimizerAlgSyncExample::initialize(const Any *input)
- throw (YACS::Exception)
- {
- }
-
- /*!
- * Optional method called when the algorithm has finished, successfully or
- * not, to perform any necessary clean up.
- */
- void OptimizerAlgSyncExample::finish()
- {
- }
-
- //! Factory method to create the algorithm.
- OptimizerAlgBase * createOptimizerAlgSyncExample(Pool *pool)
- {
- return new OptimizerAlgSyncExample(pool);
- }
-
+.. literalinclude:: ../src/yacsloader/Test/OptimizerAlgSyncExample.cxx
+ :language: cpp
Here, the entry point in the dynamic library is the name of the factory function : createOptimizerAlgSyncExample
that returns an instance of the OptimizerAlgSyncExample class that implements the algorithm.
Python plugin example
''''''''''''''''''''''
-Here, the same example of a synchronous algorithm in Python::
-
- import SALOMERuntime
-
- class myalgosync(SALOMERuntime.OptimizerAlgSync):
- def __init__(self):
- SALOMERuntime.OptimizerAlgSync.__init__(self, None)
- r=SALOMERuntime.getSALOMERuntime()
- self.tin=r.getTypeCode("double")
- self.tout=r.getTypeCode("int")
-
- def setPool(self,pool):
- """Must be implemented to set the pool"""
- self.pool=pool
-
- def getTCForIn(self):
- """returns typecode of type expected as Input"""
- return self.tin
-
- def getTCForOut(self):
- """returns typecode of type expected as Output"""
- return self.tout
-
- def initialize(self,input):
- """Optional method called on initialization. Do nothing here"""
-
- def start(self):
- """Start to fill the pool with samples to evaluate."""
- self.iter=0
- self.pool.pushInSample(4,1.2)
- self.pool.pushInSample(9,3.4)
-
- def takeDecision(self):
- """ This method is called each time a sample has been evaluated. It can
- either add new samples to evaluate in the pool, do nothing (wait for
- more samples), or empty the pool to finish the evaluation.
- """
- currentId=self.pool.getCurrentId()
-
- if self.iter==1:
- self.pool.pushInSample(16,5.6)
- self.pool.pushInSample(25,7.8)
- self.pool.pushInSample(36,9.)
- self.pool.pushInSample(49,12.3)
- elif self.iter==4:
- self.pool.pushInSample(64,45.6)
- self.pool.pushInSample(81,78.9)
- else:
- val=self.pool.getCurrentInSample()
- if abs(val.getDoubleValue()-45.6) < 1.e-12:
- self.pool.destroyAll()
- self.iter=self.iter+1
-
- def finish(self):
- """Optional method called when the algorithm has finished, successfully
- or not, to perform any necessary clean up. Do nothing here"""
+Here, the same example of a synchronous algorithm in Python:
+
+.. literalinclude:: ../src/yacsloader/Test/algosyncexample.py
Here, the entry point in the Python module is directly the name of the class that implements the algorithm : myalgosync.
- **getTCForIn**, this method must return the YACS type of the input port of the internal node
- **getTCForOut**, this method must return the YACS type of the output port of the internal node
+- **getTCForAlgoInit** (optional), this method returns the type of the "algoInit" port, string if undefined
+- **getTCForAlgoResult** (optional), this method returns the type of the "algoResult" port, string if undefined
- **initialize** (optional), this method is called during the algorithm initialization
- **startToTakeDecision**, this method is called to start the iteration process in a separate thread. It is the body of the algorithm.
- **finish** (optional), this method is called to finish the algorithm at the end of the iteration process
+- **getAlgoResult** (optional), this method returns the value of the "algoResult" port, "NULL" if undefined
In Python you need to implement another method:
''''''''''''''''''''
Here is a small example of a C++ asynchronous algorithm:
-.. code-block:: cpp
-
- #include "OptimizerAlg.hxx"
-
- using namespace YACS::ENGINE;
-
- extern "C"
- {
- OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool);
- }
-
- class OptimizerAlgASyncExample : public OptimizerAlgASync
- {
- private:
- TypeCode * _tcIn;
- TypeCode * _tcOut;
- public:
- OptimizerAlgASyncExample(Pool * pool);
- virtual ~OptimizerAlgASyncExample();
- TypeCode * getTCForIn() const;
- TypeCode * getTCForOut() const;
- void startToTakeDecision();
- };
-
- OptimizerAlgASyncExample::OptimizerAlgASyncExample(Pool * pool)
- : OptimizerAlgASync(pool), _tcIn(0), _tcOut(0)
- {
- _tcIn = new TypeCode(Double);
- _tcOut = new TypeCode(Int);
- }
-
- OptimizerAlgASyncExample::~OptimizerAlgASyncExample()
- {
- _tcIn->decrRef();
- _tcOut->decrRef();
- }
-
- //! Return the typecode of the expected input type
- TypeCode *OptimizerAlgASyncExample::getTCForIn() const
- {
- return _tcIn;
- }
-
- //! Return the typecode of the expected output type
- TypeCode *OptimizerAlgASyncExample::getTCForOut() const
- {
- return _tcOut;
- }
-
- //! This method is called only once to launch the algorithm.
- /*!
- * It must first fill the pool with samples to evaluate and call
- * signalMasterAndWait() to block until a sample has been evaluated. When
- * returning from this method, it MUST check for an eventual termination
- * request (with the method isTerminationRequested()). If the termination
- * is requested, the method must perform any necessary cleanup and return
- * as soon as possible. Otherwise it can either add new samples to evaluate
- * in the pool, do nothing (wait for more samples), or empty the pool and
- * return to finish the evaluation.
- */
- void OptimizerAlgASyncExample::startToTakeDecision()
- {
- double val = 1.2;
- for (int i=0 ; i<5 ; i++) {
- // push a sample in the input of the slave node
- _pool->pushInSample(i, AtomAny::New(val));
- // wait until next sample is ready
- signalMasterAndWait();
- // check error notification
- if (isTerminationRequested()) {
- _pool->destroyAll();
- return;
- }
-
- // get a sample from the output of the slave node
- Any * v = _pool->getCurrentOutSample();
- val += v->getIntValue();
- }
-
- // in the end destroy the pool content
- _pool->destroyAll();
- }
-
- //! Factory method to create the algorithm.
- OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool)
- {
- return new OptimizerAlgASyncExample(pool);
- }
+.. literalinclude:: ../src/yacsloader/Test/OptimizerAlgASyncExample.cxx
+ :language: cpp
Here, the entry point in the dynamic library is the name of the factory function : createOptimizerAlgASyncExample
Python plugin example
''''''''''''''''''''''''
-Here is an example of an asynchronous algorithm implemented in Python::
-
- import SALOMERuntime
-
- class myalgoasync(SALOMERuntime.OptimizerAlgASync):
- def __init__(self):
- SALOMERuntime.OptimizerAlgASync.__init__(self, None)
- r=SALOMERuntime.getSALOMERuntime()
- self.tin=r.getTypeCode("double")
- self.tout=r.getTypeCode("int")
-
- def setPool(self,pool):
- """Must be implemented to set the pool"""
- self.pool=pool
-
- def getTCForIn(self):
- """returns typecode of type expected as Input"""
- return self.tin
-
- def getTCForOut(self):
- """returns typecode of type expected as Output"""
- return self.tout
-
- def startToTakeDecision(self):
- """This method is called only once to launch the algorithm. It must
- first fill the pool with samples to evaluate and call
- self.signalMasterAndWait() to block until a sample has been
- evaluated. When returning from this method, it MUST check for an
- eventual termination request (with the method
- self.isTerminationRequested()). If the termination is requested, the
- method must perform any necessary cleanup and return as soon as
- possible. Otherwise it can either add new samples to evaluate in the
- pool, do nothing (wait for more samples), or empty the pool and
- return to finish the evaluation.
- """
- val=1.2
- for iter in xrange(5):
- #push a sample in the input of the slave node
- self.pool.pushInSample(iter,val)
- #wait until next sample is ready
- self.signalMasterAndWait()
- #check error notification
- if self.isTerminationRequested():
- self.pool.destroyAll()
- return
-
- #get a sample from the output of the slave node
- currentId=self.pool.getCurrentId()
- v=self.pool.getCurrentOutSample()
- val=val+v.getIntValue()
-
- #in the end destroy the pool content
- self.pool.destroyAll()
+Here is an example of an asynchronous algorithm implemented in Python:
+
+.. literalinclude:: ../src/yacsloader/Test/algoasyncexample.py
Here, the entry point in the Python module is directly the name of the class that implements the algorithm : myalgoasync.
+Managing the pool of samples
+---------------------------------
+
+Samples can be added to the pool at the initialization of the algorithm or
+every time a sample is evaluated (while "taking decision").
+The algorithm stops to take decisions when every sample is evaluated.
+
+A sample has:
+
+- an identifier - *Id*
+- a priority - it is used to choose the order of evaluation
+- a value - *In*
+- an evaluated or computed value - *Out*
+
+The current sample is the sample used by the latest terminated evaluation.
+
+These are the methods needed to manage the pool of samples:
+
+.. code-block:: cpp
+
+ class Pool
+ {
+ //...
+ public:
+ //For algorithm use
+ int getCurrentId() const ;
+ Any *getCurrentInSample() const ;
+ Any *getCurrentOutSample() const ;
+ Any *getOutSample(int id);
+ void pushInSample(int id, Any *inSample, unsigned char priority = 0);
+ void destroyAll();
+ //...
+ }
+
+In C++, the samples are of type ``YACS::ENGINE::Any``, in order to support any
+type supported by YACS. For conversion to standard types, use:
+
+- ``getIntValue``
+- ``getBoolValue``
+- ``getDoubleValue``
+- ``getStringValue``
+
+It is possible to create a pointer to a new object with:
+
+- ``YACS::ENGINE::AtomAny::New``
+
+For further information, see `include/salome/Any.hxx <file:../../../../../include/salome/Any.hxx>`_.
C++ algorithm calling Python code
--------------------------------------------------
SALOME application is used. Otherwise, the PYTHONPATH environment variable has to be set to
<YACS_ROOT_DIR>/lib/pythonX.Y/site-packages/salome.
+When you build your own Salome application and use your own modules and components (using YACSGEN for example), you may need to load
+the module catalog::
+
+ import SALOMERuntime
+ SALOMERuntime.RuntimeSALOME_setRuntime()
+ salome_runtime = SALOMERuntime.getSALOMERuntime()
+ import salome
+ salome.salome_init()
+ mc = salome.naming_service.Resolve('/Kernel/ModulCatalog')
+ ior = salome.orb.object_to_string(mc)
+ session_catalog = salome_runtime.loadCatalog("session", ior)
+ salome_runtime.addCatalog(session_catalog)
+
+
.. _loadxml:
Create a calculation scheme by loading an XML file
Dataflow link
++++++++++++++++++++++++++++
-The first step in defining a dataflow link is to obtain port objects using one of the methods described above.
-The edAddDFLink method for the context node is then used, transferring the two ports to be connected to it.
-The following gives an example of a dataflow link between the output port p1 of node n3 and the input port of node n4::
+The first step in defining a dataflow link is to obtain port objects using one of the methods described above.
+Then, the edAddLink method links an output port to an input port::
pout=n3.getOutputPort("p1")
pin=n4.getInputPort("p1")
- p.edAddDFLink(pout,pin)
+ p.edAddLink(pout,pin)
-Data link
-++++++++++++++++++++++++++++
-A data link is defined as being a dataflow link using the edAddLink method instead of edAddDFLink.
-The same example as above with a data link::
+Most of the time, when you need a dataflow link between two ports, you also need a control link between the nodes
+of the ports. In this case you can use the method edAddDFLink::
pout=n3.getOutputPort("p1")
pin=n4.getInputPort("p1")
- p.edAddLink(pout,pin)
+ p.edAddDFLink(pout,pin)
+
+edAddDFLink is equivalent to edAddCFLink followed by edAddLink.
Initialising an input data port
'''''''''''''''''''''''''''''''''''''''''''''''
r = pilot.getRuntime()
p=r.createProc("pr")
ti=p.getTypeCode("int")
+ td=p.getTypeCode("double")
#node1
n1=r.createScriptNode("","node1")
p.edAddChild(n1)
p.edAddCFLink(n1,n2)
p.edAddCFLink(n1,n4)
#dataflow links
- pout=n3.getOutputPort("p1")
- pin=n4.getInputPort("p1")
- #dataflow links
- p.edAddDFLink(n1.getOutputPort("p1"),n2.getInputPort("p1"))
- p.edAddDFLink(n1.getOutputPort("p1"),n4.getInputPort("p1"))
+ p.edAddLink(n1.getOutputPort("p1"),n2.getInputPort("p1"))
+ p.edAddLink(n1.getOutputPort("p1"),n4.getInputPort("p1"))
#initialisation ports
n1.getInputPort("p1").edInitPy(5)
n2.setScript("p1=2*p1")
n2.edAddInputPort("p1",ti)
n2.edAddOutputPort("p1",ti)
- b.edAddCFLink(n1,n2)
b.edAddDFLink(n1.getOutputPort("p1"),n2.getInputPort("p1"))
.. _py_forloop:
from module_generator import Generator,Module,PYComponent
from module_generator import CPPComponent,Service,F77Component
+ from module_generator import Library
If you want to import all definitions, you can do that::
body="outputport=myfunc(inputport);",
),
],
- libs="-L/usr/local/mysoft -lmybib",
- rlibs="-Wl,--rpath -Wl,/usr/local/mysoft"
+ libs=[Library(name="mybib", path="/usr/local/mysoft")],
+ rlibs="/usr/local/mysoft"
)
+**libs** contains a list of **Library** objects. On linux, if the name of the file is "libmybib.so",
+the **name** of the library will be "mybib". The *path* shows where the library is installed.
+
The **rlibs** attribute is not compulsory but it can be used to indicate a search path for dynamic libraries in execution.
**libs** is used during the link phase. **rlibs** is only used during execution, it avoids the need to set the LD_LIBRARY_PATH
environment variable to find the dynamic library.
defs="""#include "myinclude.h" """
-The includes path will be specified in the **includes** attribute of the component in the following form::
+The include paths will be specified in the **includes** attribute of the component in the following form::
defs="""#include "myinclude.h"
body="outputport=myfunc(inputport);",
),
],
- libs="-L/usr/local/mysoft -lmybib",
- rlibs="-Wl,--rpath -Wl,/usr/local/mysoft",
- includes="-I/usr/local/mysoft/include",
+ libs=[Library(name="mybib", path="/usr/local/mysoft")],
+ rlibs="/usr/local/mysoft",
+ includes="/usr/local/mysoft/include",
)
+Multiple include paths should be separated by spaces or end of line character (\\n).
+
Adding sources
""""""""""""""""""""""""""""""""""""""""""""""""""""
It is possible to add some source files with the **sources** attribute (a list of source files will be given).
),
],
sources=["myfunc.cpp"],
- includes="-I/usr/local/mysoft/include",
+ includes="/usr/local/mysoft/include",
)
body="chdir(c);"
),
],
- libs="-L/usr/local/fcompo -lfcompo",
- rlibs="-Wl,--rpath -Wl,/usr/local/fcompo"
+ libs=[Library(name="fcompo", path="/usr/local/fcompo")],
+ rlibs="/usr/local/fcompo"
)
The Fortran “compo3” component has dataflow and datastream ports like the C++ component. The Fortran dynamic library
Once this generator has been created, simply call its commands to perform the necessary operations.
- SALOME module generation: ``g.generate()``
-- initialise automake: ``g.bootstrap()``
-- execute the configure script: ``g.configure()``
+- build configuration: ``g.configure()``
- compilation: ``g.make()``
- installation in the directory <prefix>: ``g.install()``
- create a SALOME application in the directory **appli_dir**::
body="chdir(c);"
),
],
- libs="-L/local/chris/modulegen/YACSGEN/fcompo -lfcompo",
- rlibs="-Wl,--rpath -Wl,/local/chris/modulegen/YACSGEN/fcompo")
+ libs=[Library(name="fcompo", path="/local/chris/modulegen/YACSGEN/fcompo")],
+ rlibs="/local/chris/modulegen/YACSGEN/fcompo")
m=Module("mymodule",components=[c1],prefix="Install")
g=Generator(m,context)
g.generate()
- g.bootstrap()
g.configure()
g.make()
g.install()
g=Generator(Module("astmod",components=[c1,c2],prefix=install_prefix),context)
g.generate()
- g.bootstrap()
g.configure()
g.make()
g.install()
.. autoclass:: Module
.. autoclass:: Generator
- :members: generate, bootstrap, configure, make, install, make_appli
+ :members: generate, configure, make, install, make_appli
.. autofunction:: add_type
class Any;
class OptimizerLoop;
+ /*! \brief Pool used to manage the samples of the optimizer loop plugin.
+ *
+ * Every sample has an identifier (Id), a priority, an initial value (In)
+ * and an evaluation value (Out).
+ * The current sample is the sample used by the latest terminated evaluation.
+ */
class YACSLIBENGINE_EXPORT Pool
{
friend class OptimizerLoop;
#include "OptimizerAlg.hxx"
-using namespace YACS::ENGINE;
+#include <iostream>
+//using namespace YACS::ENGINE;
extern "C"
{
- OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool);
+ YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgASyncExample(YACS::ENGINE::Pool * pool);
}
-class OptimizerAlgASyncExample : public OptimizerAlgASync
- {
+class OptimizerAlgASyncExample : public YACS::ENGINE::OptimizerAlgASync
+{
private:
- TypeCode * _tcIn;
- TypeCode * _tcOut;
+ YACS::ENGINE::TypeCode *_tcInt;
+ YACS::ENGINE::TypeCode *_tcDouble;
public:
- OptimizerAlgASyncExample(Pool * pool);
+ OptimizerAlgASyncExample(YACS::ENGINE::Pool *pool);
virtual ~OptimizerAlgASyncExample();
- TypeCode * getTCForIn() const;
- TypeCode * getTCForOut() const;
- void startToTakeDecision();
- };
+
+ //! returns typecode of type expected as Input. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForIn() const;
+ //! returns typecode of type expected as Output. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForOut() const;
+ //! returns typecode of type expected for algo initialization. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const;
+ //! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const;
+ virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception);
+ virtual void startToTakeDecision();
+ virtual void finish();//! Called when optimization has succeed.
+ virtual YACS::ENGINE::Any * getAlgoResult();
+};
-OptimizerAlgASyncExample::OptimizerAlgASyncExample(Pool * pool) : OptimizerAlgASync(pool),
- _tcIn(0), _tcOut(0)
+OptimizerAlgASyncExample::OptimizerAlgASyncExample(YACS::ENGINE::Pool *pool)
+ : YACS::ENGINE::OptimizerAlgASync(pool), _tcInt(0), _tcDouble(0)
{
- _tcIn = new TypeCode(Double);
- _tcOut = new TypeCode(Int);
+ _tcDouble = new YACS::ENGINE::TypeCode(YACS::ENGINE::Double);
+ _tcInt = new YACS::ENGINE::TypeCode(YACS::ENGINE::Int);
}
OptimizerAlgASyncExample::~OptimizerAlgASyncExample()
{
- _tcIn->decrRef();
- _tcOut->decrRef();
+ _tcDouble->decrRef();
+ _tcInt->decrRef();
+}
+
+//! Return the typecode of the expected input of the internal node
+YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForIn() const
+{
+ return _tcDouble;
+}
+
+//! Return the typecode of the expected output of the internal node
+YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForOut() const
+{
+ return _tcInt;
}
-//! Return the typecode of the expected input type
-TypeCode *OptimizerAlgASyncExample::getTCForIn() const
+//! Return the typecode of the expected input of the algorithm (algoInit port)
+YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForAlgoInit() const
{
- return _tcIn;
+ return _tcInt;
}
-//! Return the typecode of the expected output type
-TypeCode *OptimizerAlgASyncExample::getTCForOut() const
+//! Return the typecode of the expected output of the algorithm (algoResult port)
+YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForAlgoResult() const
{
- return _tcOut;
+ return _tcInt;
+}
+
+//! Optional method to initialize the algorithm.
+/*!
+ * For now, the parameter input is always NULL. It might be used in the
+ * future to initialize an algorithm with custom data.
+ */
+void OptimizerAlgASyncExample::initialize(const YACS::ENGINE::Any *input)
+ throw (YACS::Exception)
+{
+ std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl;
}
//! This method is called only once to launch the algorithm.
/*!
- * It must first fill the pool with samples to evaluate and call signalMasterAndWait()
- * to block until a sample has been evaluated. When returning from this method, it MUST
- * check for an eventual termination request (with the method isTerminationRequested()).
- * If the termination is requested, the method must perform any necessary cleanup and
- * return as soon as possible. Otherwise it can either add new samples to evaluate in
- * the pool, do nothing (wait for more samples), or empty the pool and return to finish
- * the evaluation.
+ * It must first fill the pool with samples to evaluate and call
+ * signalMasterAndWait() to block until a sample has been evaluated. When
+ * returning from this method, it MUST check for an eventual termination
+ * request (with the method isTerminationRequested()). If the termination
+ * is requested, the method must perform any necessary cleanup and return
+ * as soon as possible. Otherwise it can either add new samples to evaluate
+ * in the pool, do nothing (wait for more samples), or empty the pool and
+ * return to finish the evaluation.
*/
void OptimizerAlgASyncExample::startToTakeDecision()
{
- double val = 1.2;
- for (int i=0 ; i<5 ; i++) {
- // push a sample in the input of the slave node
- _pool->pushInSample(i, AtomAny::New(val));
- // wait until next sample is ready
- signalMasterAndWait();
- // check error notification
- if (isTerminationRequested()) {
- _pool->destroyAll();
- return;
+ std::cout << "startToTakeDecision" << std::endl;
+ int iter = 0;
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(0.5);
+ _pool->pushInSample(iter, val);
+
+ signalMasterAndWait();
+ while(!isTerminationRequested())
+ {
+ int currentId = _pool->getCurrentId();
+ double valIn = _pool->getCurrentInSample()->getDoubleValue();
+ int valOut = _pool->getCurrentOutSample()->getIntValue();
+
+ std::cout << "Compute currentId=" << currentId;
+ std::cout << ", valIn=" << valIn;
+ std::cout << ", valOut=" << valOut << std::endl;
+
+ iter++;
+ if(iter < 3)
+ {
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(valIn + 1);
+ _pool->pushInSample(iter, val);
}
-
- // get a sample from the output of the slave node
- Any * v = _pool->getCurrentOutSample();
- val += v->getIntValue();
+ signalMasterAndWait();
}
+}
- // in the end destroy the pool content
+/*!
+ * Optional method called when the algorithm has finished, successfully or
+ * not, to perform any necessary clean up.
+ */
+void OptimizerAlgASyncExample::finish()
+{
+ std::cout << "Algo finish" << std::endl;
_pool->destroyAll();
}
+/*!
+ * Return the value of the algoResult port.
+ */
+YACS::ENGINE::Any * OptimizerAlgASyncExample::getAlgoResult()
+{
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(42);
+ return val;
+}
+
//! Factory method to create the algorithm.
-OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool)
+YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgASyncExample(YACS::ENGINE::Pool *pool)
{
return new OptimizerAlgASyncExample(pool);
-}
+}
\ No newline at end of file
#include "OptimizerAlg.hxx"
-using namespace YACS::ENGINE;
+#include <iostream>
+//using namespace YACS::ENGINE;
extern "C"
{
- OptimizerAlgBase * createOptimizerAlgSyncExample(Pool * pool);
+ YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgSyncExample(YACS::ENGINE::Pool * pool);
}
-class OptimizerAlgSyncExample : public OptimizerAlgSync
- {
+class OptimizerAlgSyncExample : public YACS::ENGINE::OptimizerAlgSync
+{
private:
- int _idTest;
- TypeCode *_tcIn;
- TypeCode *_tcOut;
+ int _iter;
+ YACS::ENGINE::TypeCode *_tcInt;
+ YACS::ENGINE::TypeCode *_tcDouble;
public:
- OptimizerAlgSyncExample(Pool *pool);
+ OptimizerAlgSyncExample(YACS::ENGINE::Pool *pool);
virtual ~OptimizerAlgSyncExample();
- TypeCode *getTCForIn() const;
- TypeCode *getTCForOut() const;
- void start();
- void takeDecision();
- void initialize(const Any *input) throw(YACS::Exception);
- void finish();
- };
-
-OptimizerAlgSyncExample::OptimizerAlgSyncExample(Pool *pool) : OptimizerAlgSync(pool),
- _tcIn(0), _tcOut(0),
- _idTest(0)
+
+ //! returns typecode of type expected as Input. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForIn() const;
+ //! returns typecode of type expected as Output. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForOut() const;
+ //! returns typecode of type expected for algo initialization. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const;
+ //! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
+ virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const;
+ virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception);
+ virtual void start(); //! Update _pool attribute before performing anything.
+ virtual void takeDecision();//! _pool->getCurrentId gives the \b id at the origin of this call.
+ //! Perform the job of analysing to know what new jobs to do (_pool->pushInSample)
+ //! or in case of convergence _pool->destroyAll
+ virtual void finish();//! Called when optimization has succeed.
+ virtual YACS::ENGINE::Any * getAlgoResult();
+};
+
+OptimizerAlgSyncExample::OptimizerAlgSyncExample(YACS::ENGINE::Pool *pool)
+ : YACS::ENGINE::OptimizerAlgSync(pool), _tcInt(0), _tcDouble(0), _iter(0)
{
- _tcIn=new TypeCode(Double);
- _tcOut=new TypeCode(Int);
+ _tcDouble = new YACS::ENGINE::TypeCode(YACS::ENGINE::Double);
+ _tcInt = new YACS::ENGINE::TypeCode(YACS::ENGINE::Int);
}
OptimizerAlgSyncExample::~OptimizerAlgSyncExample()
{
- std::cout << "Destroying OptimizerAlgSyncExample" << std::endl;
- _tcIn->decrRef();
- _tcOut->decrRef();
- std::cout << "Destroyed OptimizerAlgSyncExample" << std::endl;
+ _tcDouble->decrRef();
+ _tcInt->decrRef();
}
-//! Return the typecode of the expected input type
-TypeCode * OptimizerAlgSyncExample::getTCForIn() const
+//! Return the typecode of the expected input of the internal node
+YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForIn() const
{
- return _tcIn;
+ return _tcDouble;
}
-//! Return the typecode of the expected output type
-TypeCode * OptimizerAlgSyncExample::getTCForOut() const
+//! Return the typecode of the expected output of the internal node
+YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForOut() const
{
- return _tcOut;
+ return _tcInt;
+}
+
+//! Return the typecode of the expected input of the algorithm (algoInit port)
+YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForAlgoInit() const
+{
+ return _tcInt;
+}
+
+//! Return the typecode of the expected output of the algorithm (algoResult port)
+YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForAlgoResult() const
+{
+ return _tcInt;
+}
+
+//! Optional method to initialize the algorithm.
+/*!
+ * For now, the parameter input is always NULL. It might be used in the
+ * future to initialize an algorithm with custom data.
+ */
+void OptimizerAlgSyncExample::initialize(const YACS::ENGINE::Any *input)
+ throw (YACS::Exception)
+{
+ std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl;
}
//! Start to fill the pool with samples to evaluate
void OptimizerAlgSyncExample::start()
{
- _idTest=0;
- Any *val=AtomAny::New(1.2);
- _pool->pushInSample(4,val);
- val=AtomAny::New(3.4);
- _pool->pushInSample(9,val);
+ std::cout << "Algo start " << std::endl;
+ _iter=0;
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(0.5);
+ _pool->pushInSample(_iter,val);
}
//! This method is called each time a sample has been evaluated.
/*!
- * It can either add new samples to evaluate in the pool, do nothing (wait for more
- * samples), or empty the pool to finish the evaluation.
+ * It can either add new samples to evaluate in the pool, do nothing (wait
+ * for more samples), or empty the pool to finish the evaluation.
*/
void OptimizerAlgSyncExample::takeDecision()
{
- if(_idTest==1)
- {
- Any *val=AtomAny::New(5.6);
- _pool->pushInSample(16,val);
- val=AtomAny::New(7.8);
- _pool->pushInSample(25,val);
- val=AtomAny::New(9. );
- _pool->pushInSample(36,val);
- val=AtomAny::New(12.3);
- _pool->pushInSample(49,val);
- }
- else if(_idTest==4)
- {
- Any *val=AtomAny::New(45.6);
- _pool->pushInSample(64,val);
- val=AtomAny::New(78.9);
- _pool->pushInSample(81,val);
- }
- else
- {
- Any *tmp= _pool->getCurrentInSample();
- if(fabs(tmp->getDoubleValue()-45.6)<1.e-12)
- _pool->destroyAll();
- }
- _idTest++;
+ int currentId = _pool->getCurrentId();
+ double valIn = _pool->getCurrentInSample()->getDoubleValue();
+ int valOut = _pool->getCurrentOutSample()->getIntValue();
+
+ std::cout << "Algo takeDecision currentId=" << currentId;
+ std::cout << ", valIn=" << valIn;
+ std::cout << ", valOut=" << valOut << std::endl;
+
+ _iter++;
+ if(_iter < 3)
+ {
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(valIn + 1);
+ _pool->pushInSample(_iter, val);
+ }
}
-//! Optional method to initialize the algorithm.
/*!
- * For now, the parameter input is always NULL. It might be used in the future to
- * initialize an algorithm with custom data.
+ * Optional method called when the algorithm has finished, successfully or
+ * not, to perform any necessary clean up.
*/
-void OptimizerAlgSyncExample::initialize(const Any *input) throw (YACS::Exception)
+void OptimizerAlgSyncExample::finish()
{
+ std::cout << "Algo finish" << std::endl;
+ _pool->destroyAll();
}
/*!
- * Optional method called when the algorithm has finished, successfully or not, to
- * perform any necessary clean up.
+ * Return the value of the algoResult port.
*/
-void OptimizerAlgSyncExample::finish()
+YACS::ENGINE::Any * OptimizerAlgSyncExample::getAlgoResult()
{
+ YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(42);
+ return val;
}
//! Factory method to create the algorithm.
-OptimizerAlgBase * createOptimizerAlgSyncExample(Pool *pool)
+YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgSyncExample(YACS::ENGINE::Pool *pool)
{
return new OptimizerAlgSyncExample(pool);
-}
+}
\ No newline at end of file
r=SALOMERuntime.getSALOMERuntime()
self.tin=r.getTypeCode("double")
self.tout=r.getTypeCode("int")
+ self.tAlgoInit=r.getTypeCode("int")
+ self.tAlgoResult=r.getTypeCode("int")
def setPool(self,pool):
"""Must be implemented to set the pool"""
self.pool=pool
def getTCForIn(self):
- """returns typecode of type expected as Input"""
+ """return typecode of type expected as Input of the internal node """
return self.tin
def getTCForOut(self):
- """returns typecode of type expected as Output"""
+ """return typecode of type expected as Output of the internal node"""
return self.tout
- def startToTakeDecision(self):
- """This method is called only once to launch the algorithm. It must first fill the
- pool with samples to evaluate and call self.signalMasterAndWait() to block until a
- sample has been evaluated. When returning from this method, it MUST check for an
- eventual termination request (with the method self.isTerminationRequested()). If
- the termination is requested, the method must perform any necessary cleanup and
- return as soon as possible. Otherwise it can either add new samples to evaluate in
- the pool, do nothing (wait for more samples), or empty the pool and return to
- finish the evaluation.
+ def getTCForAlgoInit(self):
+ """return typecode of type expected as input for initialize """
+ return self.tAlgoInit
+
+ def getTCForAlgoResult(self):
+ """return typecode of type expected as output of the algorithm """
+ return self.tAlgoResult
+
+ def initialize(self,input):
+ """Optional method called on initialization.
+ The type of "input" is returned by "getTCForAlgoInit"
"""
- val=1.2
- for iter in xrange(5):
- #push a sample in the input of the slave node
- self.pool.pushInSample(iter,val)
- #wait until next sample is ready
- self.signalMasterAndWait()
- #check error notification
- if self.isTerminationRequested():
- self.pool.destroyAll()
- return
+ print "Algo initialize, input = ", input.getIntValue()
- #get a sample from the output of the slave node
+ def startToTakeDecision(self):
+ """This method is called only once to launch the algorithm. It must
+ first fill the pool with samples to evaluate and call
+ self.signalMasterAndWait() to block until a sample has been
+ evaluated. When returning from this method, it MUST check for an
+ eventual termination request (with the method
+ self.isTerminationRequested()). If the termination is requested, the
+ method must perform any necessary cleanup and return as soon as
+ possible. Otherwise it can either add new samples to evaluate in the
+ pool, do nothing (wait for more samples), or empty the pool and
+ return to finish the evaluation.
+ """
+ print "startToTakeDecision"
+ # fill the pool with samples
+ iter=0
+ self.pool.pushInSample(0, 0.5)
+
+ #
+ self.signalMasterAndWait()
+ while not self.isTerminationRequested():
currentId=self.pool.getCurrentId()
- v=self.pool.getCurrentOutSample()
- val=val+v.getIntValue()
+ valIn = self.pool.getCurrentInSample().getDoubleValue()
+ valOut = self.pool.getCurrentOutSample().getIntValue()
+ print "Compute currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
+ iter=iter+1
+
+ if iter < 3:
+ nextSample = valIn + 1
+ self.pool.pushInSample(iter, nextSample)
+
+ self.signalMasterAndWait()
- #in the end destroy the pool content
+ def finish(self):
+ """Optional method called when the algorithm has finished, successfully
+ or not, to perform any necessary clean up."""
+ print "Algo finish"
self.pool.destroyAll()
+
+ def getAlgoResult(self):
+ """return the result of the algorithm.
+ The object returned is of type indicated by getTCForAlgoResult.
+ """
+ return 42
+
+
r=SALOMERuntime.getSALOMERuntime()
self.tin=r.getTypeCode("double")
self.tout=r.getTypeCode("int")
+ self.tAlgoInit=r.getTypeCode("int")
+ self.tAlgoResult=r.getTypeCode("int")
def setPool(self,pool):
"""Must be implemented to set the pool"""
self.pool=pool
def getTCForIn(self):
- """returns typecode of type expected as Input"""
+ """return typecode of type expected as Input of the internal node """
return self.tin
def getTCForOut(self):
- """returns typecode of type expected as Output"""
+ """return typecode of type expected as Output of the internal node"""
return self.tout
+ def getTCForAlgoInit(self):
+ """return typecode of type expected as input for initialize """
+ return self.tAlgoInit
+
+ def getTCForAlgoResult(self):
+ """return typecode of type expected as output of the algorithm """
+ return self.tAlgoResult
+
def initialize(self,input):
- """Optional method called on initialization. Do nothing here"""
+ """Optional method called on initialization.
+ The type of "input" is returned by "getTCForAlgoInit"
+ """
+ print "Algo initialize, input = ", input.getIntValue()
def start(self):
"""Start to fill the pool with samples to evaluate."""
+ print "Algo start "
self.iter=0
- self.pool.pushInSample(4,1.2)
- self.pool.pushInSample(9,3.4)
+ # pushInSample(id, value)
+ self.pool.pushInSample(self.iter, 0.5)
def takeDecision(self):
- """ This method is called each time a sample has been evaluated. It can either add
- new samples to evaluate in the pool, do nothing (wait for more samples), or empty
- the pool to finish the evaluation.
+ """ This method is called each time a sample has been evaluated. It can
+ either add new samples to evaluate in the pool, do nothing (wait for
+ more samples), or empty the pool to finish the evaluation.
"""
currentId=self.pool.getCurrentId()
+ valIn = self.pool.getCurrentInSample().getDoubleValue()
+ valOut = self.pool.getCurrentOutSample().getIntValue()
+ print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
- if self.iter==1:
- self.pool.pushInSample(16,5.6)
- self.pool.pushInSample(25,7.8)
- self.pool.pushInSample(36,9.)
- self.pool.pushInSample(49,12.3)
- elif self.iter==4:
- self.pool.pushInSample(64,45.6)
- self.pool.pushInSample(81,78.9)
- else:
- val=self.pool.getCurrentInSample()
- if abs(val.getDoubleValue()-45.6) < 1.e-12:
- self.pool.destroyAll()
self.iter=self.iter+1
+ if self.iter < 3:
+ # continue
+ nextSample = valIn + 1
+ self.pool.pushInSample(self.iter, nextSample)
def finish(self):
- """Optional method called when the algorithm has finished, successfully or not, to
- perform any necessary clean up. Do nothing here"""
+ """Optional method called when the algorithm has finished, successfully
+ or not, to perform any necessary clean up."""
+ print "Algo finish"
+ self.pool.destroyAll()
+
+ def getAlgoResult(self):
+ """return the result of the algorithm.
+ The object returned is of type indicated by getTCForAlgoResult.
+ """
+ return 42
+
+
<objref name="file" id="file"/>
<type name="int" kind="int"/>
<sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
<objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqintvec" content="intvec"/>
<sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
<container name="DefaultContainer">
<property name="container_name" value="FactoryServer"/>
<property name="name" value="localhost"/>
</container>
- <optimizer name="OptimizerLoop0" nbranch="4" lib="libTestOptLoop" entry="createOptimizerAlgASyncExample">
- <inline name="PyFunction1">
- <function name="myfunc">
- <code><![CDATA[def myfunc(inValue):
- outValue = int(3*inValue+5)
- print "Received", inValue, ", returning", outValue
- return outValue
-]]></code>
- </function>
- <inport name="inValue" type="double"/>
- <outport name="outValue" type="int"/>
+ <optimizer name="OptimizerLoop1" nbranch="1" lib="libTestOptLoop" entry="createOptimizerAlgASyncExample">
+ <inline name="PyScript7">
+ <script><code><![CDATA[o9 = int(i8)
+print "traitement:", i8
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <inport name="i8" type="double"/>
+ <outport name="o9" type="int"/>
</inline>
</optimizer>
+ <datanode name="DataIn3">
+ <parameter name="o4" type="int">
+ <value><int>5</int></value>
+ </parameter>
+ </datanode>
+ <outnode name="OutNode5">
+ <parameter name="i6" type="int"/>
+ </outnode>
+ <control> <fromnode>OptimizerLoop1</fromnode> <tonode>OutNode5</tonode> </control>
+ <control> <fromnode>DataIn3</fromnode> <tonode>OptimizerLoop1</tonode> </control>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>algoResults</fromport>
+ <tonode>OutNode5</tonode> <toport>i6</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>OptimizerLoop1.PyScript7</tonode> <toport>i8</toport>
+ </datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0</fromnode> <fromport>evalSamples</fromport>
- <tonode>OptimizerLoop0.PyFunction1</tonode> <toport>inValue</toport>
+ <fromnode>DataIn3</fromnode> <fromport>o4</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>algoInit</toport>
</datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0.PyFunction1</fromnode> <fromport>outValue</fromport>
- <tonode>OptimizerLoop0</tonode> <toport>evalResults</toport>
+ <fromnode>OptimizerLoop1.PyScript7</fromnode> <fromport>o9</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>evalResults</toport>
</datalink>
<parameter>
- <tonode>OptimizerLoop0</tonode><toport>nbBranches</toport>
- <value><int>4</int></value>
+ <tonode>OptimizerLoop1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
</parameter>
- <presentation name="OptimizerLoop0" x="6" y="34" width="168" height="178.5" expanded="1" expx="6" expy="34" expWidth="168" expHeight="178.5" shownState="0"/>
- <presentation name="OptimizerLoop0.PyFunction1" x="6" y="111.5" width="158" height="63" expanded="1" expx="6" expy="111.5" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="__ROOT__" x="0" y="0" width="178" height="216.5" expanded="1" expx="0" expy="0" expWidth="178" expHeight="216.5" shownState="0"/>
+ <presentation name="DataIn3" x="11" y="86" width="158" height="63" expanded="1" expx="11" expy="86" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1" x="238.5" y="83.5" width="204.5" height="216" expanded="1" expx="238.5" expy="83.5" expWidth="204.5" expHeight="216" shownState="0"/>
+ <presentation name="OutNode5" x="488.5" y="84" width="158" height="63" expanded="1" expx="488.5" expy="84" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1.PyScript7" x="42.5" y="149" width="158" height="63" expanded="1" expx="42.5" expy="149" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="650.5" height="303.5" expanded="1" expx="0" expy="0" expWidth="650.5" expHeight="303.5" shownState="0"/>
</proc>
<objref name="file" id="file"/>
<type name="int" kind="int"/>
<sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
<objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqintvec" content="intvec"/>
<sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
<container name="DefaultContainer">
<property name="container_name" value="FactoryServer"/>
<property name="name" value="localhost"/>
</container>
- <optimizer name="OptimizerLoop0" nbranch="4" lib="algoasyncexample.py" entry="myalgoasync">
- <inline name="PyFunction0">
- <function name="myfunc">
- <code><![CDATA[def myfunc(inputValue):
- outputValue = int(inputValue*3+5)
- print "Received", inputValue, ", returning", outputValue
- return outputValue
-]]></code>
- </function>
- <inport name="inputValue" type="double"/>
- <outport name="outputValue" type="int"/>
+ <optimizer name="OptimizerLoop1" nbranch="1" lib="algoasyncexample.py" entry="myalgoasync">
+ <inline name="PyScript7">
+ <script><code><![CDATA[o9 = int(i8)
+print "traitement:", i8
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <inport name="i8" type="double"/>
+ <outport name="o9" type="int"/>
</inline>
</optimizer>
+ <datanode name="DataIn3">
+ <parameter name="o4" type="int">
+ <value><int>5</int></value>
+ </parameter>
+ </datanode>
+ <outnode name="OutNode5">
+ <parameter name="i6" type="int"/>
+ </outnode>
+ <control> <fromnode>OptimizerLoop1</fromnode> <tonode>OutNode5</tonode> </control>
+ <control> <fromnode>DataIn3</fromnode> <tonode>OptimizerLoop1</tonode> </control>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>algoResults</fromport>
+ <tonode>OutNode5</tonode> <toport>i6</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>OptimizerLoop1.PyScript7</tonode> <toport>i8</toport>
+ </datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0</fromnode> <fromport>evalSamples</fromport>
- <tonode>OptimizerLoop0.PyFunction0</tonode> <toport>inputValue</toport>
+ <fromnode>DataIn3</fromnode> <fromport>o4</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>algoInit</toport>
</datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0.PyFunction0</fromnode> <fromport>outputValue</fromport>
- <tonode>OptimizerLoop0</tonode> <toport>evalResults</toport>
+ <fromnode>OptimizerLoop1.PyScript7</fromnode> <fromport>o9</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>evalResults</toport>
</datalink>
<parameter>
- <tonode>OptimizerLoop0</tonode><toport>nbBranches</toport>
- <value><int>4</int></value>
+ <tonode>OptimizerLoop1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
</parameter>
- <presentation name="OptimizerLoop0" x="6" y="34" width="167" height="191" expanded="1" expx="6" expy="34" expWidth="167" expHeight="191" shownState="0"/>
- <presentation name="OptimizerLoop0.PyFunction0" x="5" y="124" width="158" height="63" expanded="1" expx="5" expy="124" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="__ROOT__" x="0" y="0" width="177" height="229" expanded="1" expx="0" expy="0" expWidth="177" expHeight="229" shownState="0"/>
+ <presentation name="DataIn3" x="11" y="86" width="158" height="63" expanded="1" expx="11" expy="86" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1" x="238.5" y="83.5" width="204.5" height="216" expanded="1" expx="238.5" expy="83.5" expWidth="204.5" expHeight="216" shownState="0"/>
+ <presentation name="OutNode5" x="488.5" y="84" width="158" height="63" expanded="1" expx="488.5" expy="84" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1.PyScript7" x="42.5" y="149" width="158" height="63" expanded="1" expx="42.5" expy="149" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="650.5" height="303.5" expanded="1" expx="0" expy="0" expWidth="650.5" expHeight="303.5" shownState="0"/>
</proc>
<objref name="file" id="file"/>
<type name="int" kind="int"/>
<sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
<objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqintvec" content="intvec"/>
<sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
<container name="DefaultContainer">
<property name="container_name" value="FactoryServer"/>
<property name="name" value="localhost"/>
</container>
- <optimizer name="OptimizerLoop0" nbranch="4" lib="libTestOptLoop" entry="createOptimizerAlgSyncExample">
- <inline name="PyFunction1">
- <function name="myfunc">
- <code><![CDATA[def myfunc(inValue):
- outValue = int(3*inValue+5)
- print "Received", inValue, ", returning", outValue
- return outValue
-]]></code>
- </function>
- <inport name="inValue" type="double"/>
- <outport name="outValue" type="int"/>
+ <optimizer name="OptimizerLoop1" nbranch="1" lib="libTestOptLoop" entry="createOptimizerAlgSyncExample">
+ <inline name="PyScript7">
+ <script><code><![CDATA[o9 = int(i8)
+print "traitement:", i8
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <inport name="i8" type="double"/>
+ <outport name="o9" type="int"/>
</inline>
</optimizer>
+ <datanode name="DataIn3">
+ <parameter name="o4" type="int">
+ <value><int>5</int></value>
+ </parameter>
+ </datanode>
+ <outnode name="OutNode5">
+ <parameter name="i6" type="int"/>
+ </outnode>
+ <control> <fromnode>OptimizerLoop1</fromnode> <tonode>OutNode5</tonode> </control>
+ <control> <fromnode>DataIn3</fromnode> <tonode>OptimizerLoop1</tonode> </control>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>algoResults</fromport>
+ <tonode>OutNode5</tonode> <toport>i6</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>OptimizerLoop1.PyScript7</tonode> <toport>i8</toport>
+ </datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0</fromnode> <fromport>evalSamples</fromport>
- <tonode>OptimizerLoop0.PyFunction1</tonode> <toport>inValue</toport>
+ <fromnode>DataIn3</fromnode> <fromport>o4</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>algoInit</toport>
</datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0.PyFunction1</fromnode> <fromport>outValue</fromport>
- <tonode>OptimizerLoop0</tonode> <toport>evalResults</toport>
+ <fromnode>OptimizerLoop1.PyScript7</fromnode> <fromport>o9</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>evalResults</toport>
</datalink>
<parameter>
- <tonode>OptimizerLoop0</tonode><toport>nbBranches</toport>
- <value><int>4</int></value>
+ <tonode>OptimizerLoop1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
</parameter>
- <presentation name="OptimizerLoop0" x="6" y="34" width="169" height="187.5" expanded="1" expx="6" expy="34" expWidth="169" expHeight="187.5" shownState="0"/>
- <presentation name="OptimizerLoop0.PyFunction1" x="7" y="120.5" width="158" height="63" expanded="1" expx="7" expy="120.5" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="__ROOT__" x="0" y="0" width="179" height="225.5" expanded="1" expx="0" expy="0" expWidth="179" expHeight="225.5" shownState="0"/>
+ <presentation name="DataIn3" x="11" y="86" width="158" height="63" expanded="1" expx="11" expy="86" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1" x="238.5" y="83.5" width="204.5" height="216" expanded="1" expx="238.5" expy="83.5" expWidth="204.5" expHeight="216" shownState="0"/>
+ <presentation name="OutNode5" x="488.5" y="84" width="158" height="63" expanded="1" expx="488.5" expy="84" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1.PyScript7" x="42.5" y="149" width="158" height="63" expanded="1" expx="42.5" expy="149" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="650.5" height="303.5" expanded="1" expx="0" expy="0" expWidth="650.5" expHeight="303.5" shownState="0"/>
</proc>
<objref name="file" id="file"/>
<type name="int" kind="int"/>
<sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
<objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqintvec" content="intvec"/>
<sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
<container name="DefaultContainer">
<property name="container_name" value="FactoryServer"/>
<property name="name" value="localhost"/>
</container>
- <optimizer name="OptimizerLoop0" nbranch="4" lib="algosyncexample.py" entry="myalgosync">
- <inline name="PyFunction0">
- <function name="myfunc">
- <code><![CDATA[def myfunc(inputValue):
- outputValue = int(inputValue*3+5)
- print "Received", inputValue, ", returning", outputValue
- return outputValue
-]]></code>
- </function>
- <inport name="inputValue" type="double"/>
- <outport name="outputValue" type="int"/>
+ <optimizer name="OptimizerLoop1" nbranch="1" lib="algosyncexample.py" entry="myalgosync">
+ <inline name="PyScript7">
+ <script><code><![CDATA[o9 = int(i8)
+print "traitement:", i8
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <inport name="i8" type="double"/>
+ <outport name="o9" type="int"/>
</inline>
</optimizer>
+ <datanode name="DataIn3">
+ <parameter name="o4" type="int">
+ <value><int>5</int></value>
+ </parameter>
+ </datanode>
+ <outnode name="OutNode5">
+ <parameter name="i6" type="int"/>
+ </outnode>
+ <control> <fromnode>OptimizerLoop1</fromnode> <tonode>OutNode5</tonode> </control>
+ <control> <fromnode>DataIn3</fromnode> <tonode>OptimizerLoop1</tonode> </control>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>algoResults</fromport>
+ <tonode>OutNode5</tonode> <toport>i6</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>OptimizerLoop1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>OptimizerLoop1.PyScript7</tonode> <toport>i8</toport>
+ </datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0</fromnode> <fromport>evalSamples</fromport>
- <tonode>OptimizerLoop0.PyFunction0</tonode> <toport>inputValue</toport>
+ <fromnode>DataIn3</fromnode> <fromport>o4</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>algoInit</toport>
</datalink>
<datalink control="false">
- <fromnode>OptimizerLoop0.PyFunction0</fromnode> <fromport>outputValue</fromport>
- <tonode>OptimizerLoop0</tonode> <toport>evalResults</toport>
+ <fromnode>OptimizerLoop1.PyScript7</fromnode> <fromport>o9</fromport>
+ <tonode>OptimizerLoop1</tonode> <toport>evalResults</toport>
</datalink>
<parameter>
- <tonode>OptimizerLoop0</tonode><toport>nbBranches</toport>
- <value><int>4</int></value>
+ <tonode>OptimizerLoop1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
</parameter>
- <presentation name="OptimizerLoop0.PyFunction0" x="6" y="111.5" width="158" height="63" expanded="1" expx="6" expy="111.5" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="OptimizerLoop0" x="6" y="34" width="168" height="178.5" expanded="1" expx="6" expy="34" expWidth="168" expHeight="178.5" shownState="0"/>
- <presentation name="__ROOT__" x="0" y="0" width="178" height="216.5" expanded="1" expx="0" expy="0" expWidth="178" expHeight="216.5" shownState="0"/>
+ <presentation name="DataIn3" x="11" y="86" width="158" height="63" expanded="1" expx="11" expy="86" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1" x="238.5" y="83.5" width="204.5" height="216" expanded="1" expx="238.5" expy="83.5" expWidth="204.5" expHeight="216" shownState="0"/>
+ <presentation name="OutNode5" x="488.5" y="84" width="158" height="63" expanded="1" expx="488.5" expy="84" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="OptimizerLoop1.PyScript7" x="42.5" y="149" width="158" height="63" expanded="1" expx="42.5" expy="149" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="650.5" height="303.5" expanded="1" expx="0" expy="0" expWidth="650.5" expHeight="303.5" shownState="0"/>
</proc>