Version: 9.16.0
YACS::ENGINE::OptimizerLoop Class Reference

class to build optimization loops More...

#include <OptimizerLoop.hxx>

Inheritance diagram for YACS::ENGINE::OptimizerLoop:
Collaboration diagram for YACS::ENGINE::OptimizerLoop:

Public Member Functions

 OptimizerLoop (const std::string &name, const std::string &algLibWthOutExt, const std::string &symbolNameToOptimizerAlgBaseInstanceFactory, bool algInitOnFile, bool initAlgo=true, Proc *procForTypes=NULL)
 
 OptimizerLoop (const OptimizerLoop &other, ComposedNode *father, bool editionOnly)
 
 ~OptimizerLoop ()
 
void init (bool start=true)
 
void exUpdateState ()
 Update the node state. More...
 
int getNumberOfInputPorts () const
 
InputPortedGetPortForOutPool ()
 
InputPortedGetAlgoInitPort ()
 
OutputPortedGetAlgoResultPort ()
 
InputPortgetInputPort (const std::string &name) const
 Get an input port given its name. More...
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
void selectRunnableTasks (std::vector< Task * > &tasks)
 
void getReadyTasks (std::vector< Task * > &tasks)
 
YACS::Event updateStateOnFinishedEventFrom (Node *node)
 
void checkNoCyclePassingThrough (Node *node)
 
virtual void accept (Visitor *visitor)
 
virtual std::string getSymbol () const
 
virtual std::string getAlgLib () const
 Return the name of the algorithm library. More...
 
virtual void setAlgorithm (const std::string &alglib, const std::string &symbol, bool checkLinks=true, Proc *procForTypes=NULL)
 Set the algorithm library name and factory name (symbol in library) to create the algorithm and change it if the node is not connected. More...
 
virtual void checkBasicConsistency () const
 Check validity for the node. More...
 
virtual std::string typeName ()
 
int getNumberOfOutputPorts () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
OutPortgetOutPort (const std::string &name) const
 
OutputPortgetOutputPort (const std::string &name) const
 Get an output port given its name. More...
 
YACS::Event finalize ()
 
- Public Member Functions inherited from YACS::ENGINE::DynParaLoop
NodeedRemoveNode ()
 
NodeedRemoveInitNode ()
 
NodeedRemoveFinalizeNode ()
 
NodeedSetNode (Node *DISOWNnode)
 
NodeedSetInitNode (Node *DISOWNnode)
 
NodeedSetFinalizeNode (Node *DISOWNnode)
 
virtual bool edAddDFLink (OutPort *start, InPort *end)
 Connect an OutPort to an InPort and add control link if necessary. More...
 
void init (bool start=true)
 
InputPortedGetNbOfBranchesPort ()
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
unsigned getNumberOfEltsConsumed () const
 
int getBranchIDOfNode (Node *node) const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
OutputPortedGetSamplePort ()
 
OutPortgetOutPort (const std::string &name) const
 
InputPortgetInputPort (const std::string &name) const
 Get an input port given its name. More...
 
OutputPortgetOutputPort (const std::string &name) const
 Get an output port given its name. More...
 
bool isPlacementPredictableB4Run () const
 For the moment false is returned : impovement about it coming soon. More...
 
void edRemoveChild (Node *node)
 Remove a child node. More...
 
bool isLoop () const override
 
virtual bool edAddChild (Node *DISOWNnode)
 
std::list< Node * > edGetDirectDescendants () const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
unsigned getNumberOfBranchesCreatedDyn () const
 
NodegetChildByShortName (const std::string &name) const
 
NodegetChildByNameExec (const std::string &name, unsigned id) const
 
std::vector< Node * > getNodes () const
 
ComplexWeightgetWeight ()
 
void setWeight (double loopWeight)
 
void getWeightRegardingDPL (ComplexWeight *weight)
 
bool isMultiplicitySpecified (unsigned &value) const
 
void forceMultiplicity (unsigned value)
 
virtual void checkBasicConsistency () const
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
void accept (Visitor *visitor)
 
NodegetInitNode ()
 
NodegetExecNode ()
 
NodegetFinalizeNode ()
 
int getMaxLevelOfParallelism () const
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
 
virtual void cleanDynGraph ()
 
- Public Member Functions inherited from YACS::ENGINE::ComposedNode
virtual ~ComposedNode ()
 
bool isFinished ()
 
void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the composed node. More...
 
virtual void resetState (int level)
 Reset the state of the node and its children depending on the parameter level. More...
 
std::string getName () const
 
std::string getTaskName (Task *task) const
 
DeploymentTree getDeploymentTree () const
 Essentially for test. Use checkDeploymentTree instead to be sure that returned DeploymentTree is consistent. More...
 
DeploymentTree checkDeploymentTree (bool deep) const
 Perform check of deployment consistency of the current graph. More...
 
std::vector< Task * > getNextTasks (bool &isMore)
 
virtual bool isPlacementPredictableB4Run () const =0
 
void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)
 Notify the node a task has emitted an event. More...
 
bool edAddLink (OutPort *start, InPort *end)
 Add a dataflow link between two data ports. More...
 
virtual bool edAddDFLink (OutPort *start, InPort *end)
 Connect an OutPort to an InPort and add the necessary control link. More...
 
virtual bool edAddChild (Node *DISOWNnode)
 
virtual void edRemoveChild (Node *node)
 Remove a child node. More...
 
bool edAddLink (OutGate *start, InGate *end)
 Add a controlflow link between two control ports. More...
 
bool edAddCFLink (Node *nodeS, Node *nodeE)
 Add a controlflow link between two nodes. More...
 
void edRemoveCFLink (Node *nodeS, Node *nodeE)
 Remove a controlflow link. More...
 
void edRemoveLink (OutPort *start, InPort *end)
 Remove a dataflow link. More...
 
void edRemoveLink (OutGate *start, InGate *end)
 Remove a controlflow link. More...
 
virtual bool isRepeatedUnpredictablySeveralTimes () const
 
virtual bool isLoop () const
 
virtual std::list< Node * > edGetDirectDescendants () const =0
 
virtual void removeRecursivelyRedundantCL ()
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< Node * > getAllRecursiveNodes ()
 Get all children nodes elementary and composed including this node. More...
 
virtual std::list< Node * > getAllRecursiveConstituents ()
 Idem getAllRecursiveNodes, but this node is NOT included. More...
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
std::string getInPortName (const InPort *) const
 Get the input port name. More...
 
std::string getOutPortName (const OutPort *) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::list< OutputPort * > getLocalOutputPorts () const
 redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself More...
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 List all output ports of children nodes that are linked to out of scope input ports. More...
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 List all input ports that are linked to out of scope ports. More...
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
OutPortgetOutPort (const std::string &name) const
 
InputPortgetInputPort (const std::string &name) const
 Get an input port given its name. More...
 
OutputPortgetOutputPort (const std::string &name) const
 Get an output port given its name. More...
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const
 
std::vector< std::pair< OutPort *, InPort * > > getSetOfInternalLinks () const
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const
 
void checkConsistency (LinkInfo &info) const
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void checkBasicConsistency () const
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
ComposedNodegetRootNode () const
 
bool isNodeAlreadyAggregated (const Node *node) const
 Check that Node 'node' is already a direct son of this. More...
 
virtual bool isNameAlreadyUsed (const std::string &name) const
 
NodeisInMyDescendance (Node *nodeToTest) const
 Returns the parent of a node that is the direct child of this node. More...
 
std::string getChildName (const Node *node) const
 
virtual std::string getMyQualifiedName (const Node *directSon) const
 
NodegetChildByName (const std::string &name) const
 
void loaded ()
 
void connected ()
 
void accept (Visitor *visitor)
 
virtual void cleanNodes ()
 Clean the composed node in case of not clean exit. More...
 
virtual std::string getProgress () const
 
void setProperty (const std::string &name, const std::string &value) override
 
std::string getProperty (const std::string &name) override
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
void writeDotInFile (const std::string &fileName) const
 
virtual void exUpdateState ()
 Update the node state. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
virtual void getReadyTasks (std::vector< Task * > &tasks)=0
 
virtual std::list< ElementaryNode * > getRecursiveConstituents () const =0
 
virtual std::list< ProgressWeightgetProgressWeight () const =0
 
virtual int getNumberOfInputPorts () const =0
 
virtual int getNumberOfOutputPorts () const =0
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::list< InputPort * > getSetOfInputPort () const =0
 
virtual std::list< OutputPort * > getSetOfOutputPort () const =0
 
virtual std::list< InputPort * > getLocalInputPorts () const =0
 
virtual std::list< OutputPort * > getLocalOutputPorts () const =0
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual std::string getInPortName (const InPort *) const =0
 
virtual std::string getOutPortName (const OutPort *) const =0
 
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const =0
 
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const =0
 
InPortgetInPort (const std::string &name) const
 
InPropertyPortgetInPropertyPort () const
 
virtual OutPortgetOutPort (const std::string &name) const
 
virtual std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const =0
 
virtual std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const =0
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const =0
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const =0
 
virtual InputPortgetInputPort (const std::string &name) const
 
virtual OutputPortgetOutputPort (const std::string &name) const =0
 
virtual InputDataStreamPortgetInputDataStreamPort (const std::string &name) const =0
 
virtual OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const =0
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
DynParaLoopgetClosestDPLAmongAncestors () const
 
virtual ComposedNodegetRootNode () const
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string, std::string > getProperties ()
 
std::map< std::string, std::string > getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual NodegetChildByName (const std::string &name) const =0
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
virtual void accept (Visitor *visitor)=0
 
virtual int getMaxLevelOfParallelism () const =0
 
virtual void getWeightRegardingDPL (ComplexWeight *weight)=0
 
virtual void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair< std::string, int > > getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string typeName ()
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Scheduler
virtual void init (bool start=true)=0
 
virtual bool isFinished ()=0
 
virtual void exUpdateState ()=0
 
virtual std::string getName () const =0
 
virtual std::string getTaskName (Task *task) const =0
 
virtual std::vector< Task * > getNextTasks (bool &isMore)=0
 
virtual void selectRunnableTasks (std::vector< Task * > &tasks)=0
 
virtual void notifyFrom (const Task *sender, YACS::Event event, const Executor *execInst)=0
 
virtual DeploymentTree getDeploymentTree () const =0
 
virtual bool isPlacementPredictableB4Run () const =0
 
virtual bool isMultiplicitySpecified (unsigned &value) const =0
 
virtual void forceMultiplicity (unsigned value)=0
 
virtual void setProperty (const std::string &name, const std::string &value)=0
 
virtual std::string getProperty (const std::string &name)=0
 
virtual ~Scheduler ()
 

Protected Member Functions

virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
 
void cleanInterceptors ()
 
void launchMaxOfSamples (bool first)
 
bool isFullyLazy () const
 
bool isFullyBusy (unsigned &branchId) const
 
void initInterceptors (unsigned nbOfBr)
 
void pushValueOutOfScopeForCase (unsigned branchId)
 
NodesimpleClone (ComposedNode *father, bool editionOnly=true) const
 
virtual void loadAlgorithm ()
 Load the algorithm from the dynamic library. More...
 
- Protected Member Functions inherited from YACS::ENGINE::DynParaLoop
 DynParaLoop (const std::string &name, TypeCode *typeOfDataSplitted, std::unique_ptr< NbBranchesAbstract > &&branchManager)
 
virtual ~DynParaLoop ()
 
 DynParaLoop (const DynParaLoop &other, ComposedNode *father, bool editionOnly)
 
void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
 
virtual void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
 
void prepareInputsFromOutOfScope (int branchNb)
 
void putValueOnBranch (Any *val, unsigned branchId, bool first)
 
TypeOfNode getIdentityOfNotifyerNode (const Node *node, unsigned &id)
 
InputPortgetDynInputPortByAbsName (int branchNb, const std::string &name, bool initNodeAdmitted)
 
virtual void forwardExecStateToOriginalBody (Node *execNode)
 
virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
std::vector< Node * > cloneAndPlaceNodesCoherently (const std::vector< Node * > &origNodes)
 Clone nodes and make their placement consistent with the placement of the original ones. More...
 
NodecheckConsistencyAndSetNode (Node *&nodeToReplace, Node *DISOWNnode)
 This method is used to factorize methods edSetNode, edSetInitNode and edSetFinalizeNode. More...
 
NoderemoveNode (Node *&nodeToRemove)
 This method is used to factorize methods edRemoveNode, edRemoveInitNode and edRemoveFinalizeNode. More...
 
virtual void shutdown (int level)
 Stop all pending activities of the composed node. More...
 
- Protected Member Functions inherited from YACS::ENGINE::ComposedNode
 ComposedNode (const std::string &name)
 
 ComposedNode (const ComposedNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
void edDisconnectAllLinksWithMe ()
 
virtual NodegetChildByShortName (const std::string &name) const =0
 
YACS::Event updateStateFrom (Node *node, YACS::Event event, const Executor *execInst)
 Update node state on receiving event from a node. More...
 
virtual YACS::Event updateStateOnStartEventFrom (Node *node)
 Method used to notify the node that a child node has started. More...
 
virtual YACS::Event updateStateOnFinishedEventFrom (Node *node)=0
 
virtual YACS::Event updateStateOnFailedEventFrom (Node *node, const Executor *execInst)
 Method used to notify the node that a child node has failed. More...
 
virtual void checkLinkPossibility (OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
 
virtual void buildDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void buildDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
virtual void getDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void getDelegateOf (std::pair< OutPort *, OutPort * > &port, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
virtual void releaseDelegateOf (InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
 
virtual void releaseDelegateOf (OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list< ComposedNode * > &pointsOfView)
 
virtual void checkNoCyclePassingThrough (Node *node)=0
 
void checkInMyDescendance (Node *nodeToTest) const
 Check if a node is in the descendance of this node. More...
 
template<class PORT >
std::string getPortName (const PORT *port) const
 
void checkNoCrossHierachyWith (Node *node) const
 
virtual void performCFComputations (LinkInfo &info) const
 perform recursively all CF computations. More...
 
virtual void destructCFComputations (LinkInfo &info) const
 destroy recursively all results of initial computations. More...
 
NodegetLowestNodeDealingAll (const std::list< OutPort * > &ports) const
 
void checkLinksCoherenceRegardingControl (const std::vector< OutPort * > &starts, InputPort *end, LinkInfo &info) const
 
virtual void checkControlDependancy (OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const =0
 
void solveObviousOrDelegateCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 
virtual void checkCFLinks (const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
 check control flow links More...
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void performDuplicationOfPlacement (const Node &other)=0
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
virtual void performShallowDuplicationOfPlacement (const Node &other)=0
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 
virtual void edDisconnectAllLinksWithMe ()
 

Protected Attributes

Pool _myPool
 
bool _algInitOnFile
 
std::string _symbol
 
std::string _alglib
 
AnyInputPort _algoInitPort
 
::YACS::BASES::DynLibLoader * _loader
 
OptimizerAlgBase_alg
 
AnyInputPort _retPortForOutPool
 
std::vector< bool > _initNodeUpdated
 
bool _convergenceReachedWithOtherCalc
 
FakeNodeForOptimizerLoop_nodeForSpecialCases
 
std::vector< AnyInputPort * > _interceptorsForOutPool
 
std::map< InputPort *, std::vector< InputPort * > > _interceptors
 outputports interceptors leaving current scope. More...
 
AnyOutputPort _algoResultPort
 
- Protected Attributes inherited from YACS::ENGINE::DynParaLoop
Node_node
 
Node_initNode
 
Node_finalizeNode
 
unsigned _nbOfEltConsumed
 
std::vector< int > _execIds
 
std::unique_ptr< NbBranchesAbstract_nbOfBranches
 
AnyOutputPort _splittedPort
 
std::vector< Node * > _execNodes
 
std::vector< Node * > _execInitNodes
 
std::vector< Node * > _execFinalizeNodes
 
int _initializingCounter
 
int _unfinishedCounter
 
int _failedCounter
 
ComplexWeight _weight
 
double _loopWeight
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string, std::string > _propertyMap
 
Node_eventReceiver =nullptr
 

Static Protected Attributes

static const int NOT_RUNNING_BRANCH_ID =-1973012217
 
static const int NOT_INITIALIZED_BRANCH_ID =-1973
 
static const char NAME_OF_ALGO_INIT_PORT [] = "algoInit"
 
static const char NAME_OF_OUT_POOL_INPUT [] = "evalResults"
 
static const char NAME_OF_ALGO_RESULT_PORT [] = "algoResults"
 
- Static Protected Attributes inherited from YACS::ENGINE::DynParaLoop
static const char NAME_OF_SPLITTED_SEQ_OUT [] = "evalSamples"
 
static const char OLD_NAME_OF_SPLITTED_SEQ_OUT [] = "SmplPrt"
 
- Static Protected Attributes inherited from YACS::ENGINE::ComposedNode
static const unsigned char FED_ST = 2
 
static const unsigned char FREE_ST = 0
 
static const unsigned char FED_DS_ST = 1
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Private Member Functions

TypeCodecheckTypeCode (TypeCode *tc, const char *portName)
 

Friends

class FakeNodeForOptimizerLoop
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::ComposedNode
static ComposedNodegetLowestCommonAncestor (Node *node1, Node *node2)
 Retrieves the lowest common ancestor of 2 nodes. More...
 
static std::string getLowestCommonAncestorStr (const std::string &node1, const std::string &node2)
 
- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
static void checkValidityOfNodeName (const std::string &name)
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Public Attributes inherited from YACS::ENGINE::ComposedNode
static const char SEP_CHAR_BTW_LEVEL [] ="."
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 
- Protected Types inherited from YACS::ENGINE::DynParaLoop
enum  TypeOfNode { INIT_NODE = 5 , WORK_NODE = 6 , FINALIZE_NODE = 7 }
 
- Static Protected Member Functions inherited from YACS::ENGINE::ComposedNode
static bool splitNamesBySep (const std::string &globalName, const char separator[], std::string &firstPart, std::string &lastPart, bool priority)
 Splits name globalName in 2 parts using separator. More...
 
- Static Protected Member Functions inherited from YACS::ENGINE::Node
static void checkValidityOfPortName (const std::string &name)
 
static ComposedNodecheckHavingCommonFather (Node *node1, Node *node2)
 

Detailed Description

class to build optimization loops

Definition at line 56 of file OptimizerLoop.hxx.

Constructor & Destructor Documentation

◆ OptimizerLoop() [1/2]

OptimizerLoop::OptimizerLoop ( const std::string &  name,
const std::string &  algLibWthOutExt,
const std::string &  symbolNameToOptimizerAlgBaseInstanceFactory,
bool  algInitOnFile,
bool  initAlgo = true,
Proc procForTypes = NULL 
)

Definition at line 98 of file OptimizerLoop.cxx.

100 :
101 DynParaLoop(name,Runtime::_tc_string,std::unique_ptr<NbBranchesAbstract>(new NbBranches(this))),_algInitOnFile(algInitOnFile),_alglib(algLibWthOutExt),
106{
107 //We need this because calling a virtual method in a constructor does not call the most derived method but the method of the class
108 //A derived class must take care to manage that
109 if(initAlgo)
110 setAlgorithm(algLibWthOutExt,symbolNameToOptimizerAlgBaseInstanceFactory, procForTypes);
111}
friend class DynParaLoop
Definition: Node.hxx:77
static const char NAME_OF_OUT_POOL_INPUT[]
virtual void setAlgorithm(const std::string &alglib, const std::string &symbol, bool checkLinks=true, Proc *procForTypes=NULL)
Set the algorithm library name and factory name (symbol in library) to create the algorithm and chang...
FakeNodeForOptimizerLoop * _nodeForSpecialCases
static const char NAME_OF_ALGO_INIT_PORT[]
::YACS::BASES::DynLibLoader * _loader
static const char NAME_OF_ALGO_RESULT_PORT[]
static YACS::ENGINE::TypeCode * _tc_string
Definition: Runtime.hxx:139

References setAlgorithm().

Referenced by simpleClone().

◆ OptimizerLoop() [2/2]

OptimizerLoop::OptimizerLoop ( const OptimizerLoop other,
ComposedNode father,
bool  editionOnly 
)

Definition at line 113 of file OptimizerLoop.cxx.

113 :
114 DynParaLoop(other,father,editionOnly),_algInitOnFile(other._algInitOnFile),_alglib(other._alglib),
118{
119 //Don't call setAlgorithm here because it will be called several times if the class is derived. Call it in simpleClone for cloning
120
121 // Create the links to evalResults port
122 set<OutPort *> fromPortsToReproduce=other._retPortForOutPool.edSetOutPort();
123 for(set<OutPort *>::iterator iter=fromPortsToReproduce.begin();iter!=fromPortsToReproduce.end();iter++)
125}
std::string getPortName(const PORT *port) const
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
Definition: InPort.cxx:65
OutPort * getOutPort(const std::string &name) const

References _retPortForOutPool, YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::InPort::edSetOutPort(), getOutPort(), and YACS::ENGINE::ComposedNode::getPortName().

◆ ~OptimizerLoop()

OptimizerLoop::~OptimizerLoop ( )

Member Function Documentation

◆ accept()

void OptimizerLoop::accept ( Visitor visitor)
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 695 of file OptimizerLoop.cxx.

696{
697 visitor->visitOptimizerLoop(this);
698}
virtual void visitOptimizerLoop(OptimizerLoop *node)=0

References YACS::ENGINE::Visitor::visitOptimizerLoop().

◆ buildDelegateOf() [1/2]

void OptimizerLoop::buildDelegateOf ( InPort *&  port,
OutPort initialStart,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 475 of file OptimizerLoop.cxx.

476{
477 DynParaLoop::buildDelegateOf(port,initialStart,pointsOfView);
478 if(port==&_retPortForOutPool)
479 {
480 std::string linkName("(");
481 linkName += initialStart->getName()+" to "+port->getName()+")";
482 throw Exception(std::string("Illegal OptimizerLoop link: \
483The 'evalResults' port must be linked within the scope of the loop.")
484 + linkName);
485 }
486}
std::string getName() const
Definition: DataPort.hxx:55
void buildDelegateOf(InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)

References _retPortForOutPool, YACS::ENGINE::DynParaLoop::buildDelegateOf(), and YACS::ENGINE::DataPort::getName().

◆ buildDelegateOf() [2/2]

void OptimizerLoop::buildDelegateOf ( std::pair< OutPort *, OutPort * > &  port,
InPort finalTarget,
const std::list< ComposedNode * > &  pointsOfView 
)
protectedvirtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 488 of file OptimizerLoop.cxx.

489{
490 DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView);
491 if(port.first != &_algoResultPort)
492 {
493 std::string linkName("(");
494 linkName += port.first->getName()+" to "+finalTarget->getName()+")";
495 throw Exception(std::string("Illegal OptimizerLoop link: \
496Only the algorithm result port can be linked to a port outside the scope of the loop.")
497 + linkName);
498 }
499
500 string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
501 if(typeOfPortInstance!=OutputPort::NAME)
502 throw Exception("OptimizerLoop::buildDelegateOf : not implemented for DS because not specified ");
503}
static const char NAME[]
Definition: OutputPort.hxx:79

References _algoResultPort, YACS::ENGINE::DynParaLoop::buildDelegateOf(), YACS::ENGINE::DataPort::getName(), and YACS::ENGINE::OutputPort::NAME.

◆ checkBasicConsistency()

void OptimizerLoop::checkBasicConsistency ( ) const
virtual

Check validity for the node.

Throw an exception if the node is not valid

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 802 of file OptimizerLoop.cxx.

803{
804 DEBTRACE("OptimizerLoop::checkBasicConsistency");
805 if (_alglib == "")
806 throw Exception("No library specified for the OptimizerLoop control algorithm");
807 if (_symbol == "")
808 throw Exception("No symbol specified for the OptimizerLoop control algorithm");
809 if(_alg == NULL)
810 throw YACS::Exception("Problem during library loading: "+_errorDetails);
811
813}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual void checkBasicConsistency() const
std::string _errorDetails
Definition: Node.hxx:93

References _alg, _alglib, YACS::ENGINE::Node::_errorDetails, _symbol, YACS::ENGINE::DynParaLoop::checkBasicConsistency(), and DEBTRACE.

◆ checkCFLinks()

void OptimizerLoop::checkCFLinks ( const std::list< OutPort * > &  starts,
InputPort end,
unsigned char &  alreadyFed,
bool  direction,
LinkInfo info 
) const
protectedvirtual

check control flow links

Parameters
startsIf different of 0, must aggregate at leat 1 element.
end:
alreadyFedin/out parameter. Indicates if 'end' ports is already and surely set or fed by an another port.
directionIf true : forward direction else backward direction.
info: informations collectedduring the check

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 517 of file OptimizerLoop.cxx.

518{
519 if(end==&_retPortForOutPool)
520 solveObviousOrDelegateCFLinks(starts,end,alreadyFed,direction,info);
521 else
522 DynParaLoop::checkCFLinks(starts,end,alreadyFed,direction,info);
523}
void solveObviousOrDelegateCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links

References _retPortForOutPool, YACS::ENGINE::DynParaLoop::checkCFLinks(), and YACS::ENGINE::ComposedNode::solveObviousOrDelegateCFLinks().

◆ checkControlDependancy()

void OptimizerLoop::checkControlDependancy ( OutPort start,
InPort end,
bool  cross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  fw,
std::vector< OutPort * > &  fwCross,
std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &  bw,
LinkInfo info 
) const
protectedvirtual
Parameters
start: start port
end: end port
crossindicates if start -> end link is a DS link behind.
fwout parameter.
fwCrossout parameter storing links where a cross has been detected.
bwout parameter where backward links are stored.
info: collected information

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 505 of file OptimizerLoop.cxx.

510{
511 if(end==&_retPortForOutPool)
512 fw[(ComposedNode *)this].push_back(start);
513 else
514 DynParaLoop::checkControlDependancy(start,end,cross,fw,fwCross,bw,info);
515}
Base class for all composed nodes.
void checkControlDependancy(OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const

References _retPortForOutPool, and YACS::ENGINE::DynParaLoop::checkControlDependancy().

◆ checkLinkPossibility()

void OptimizerLoop::checkLinkPossibility ( OutPort start,
const std::list< ComposedNode * > &  pointsOfViewStart,
InPort end,
const std::list< ComposedNode * > &  pointsOfViewEnd 
)
protectedvirtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 525 of file OptimizerLoop.cxx.

527{
528 DynParaLoop::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
529 std::string linkName("(");
530 linkName += start->getName()+" to "+end->getName()+")";
531
532 // Yes, it should be possible to link back the result port to any input port of the loop.
533 if(end == _nbOfBranches->getPort() || end == &_algoInitPort)
534 if(start != &_algoResultPort)
535 throw Exception(std::string("Illegal OptimizerLoop link.") + linkName);
536 else
537 return;
538
539 if(start == &_algoResultPort)
540 throw Exception(std::string("Illegal OptimizerLoop link: \
541The 'algoResult' port can't be linked within the scope of the loop.") + linkName);
542
543 if(end == &_retPortForOutPool && isInMyDescendance(start->getNode())!=_node)
544 throw Exception(std::string("Illegal OptimizerLoop link: \
545The 'evalResults' port can only be linked to the working node.") + linkName);
546}
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
virtual void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
std::unique_ptr< NbBranchesAbstract > _nbOfBranches
Definition: DynParaLoop.hxx:56
Node * getNode() const
Definition: Port.hxx:46

References _algoInitPort, _algoResultPort, YACS::ENGINE::DynParaLoop::_nbOfBranches, YACS::ENGINE::DynParaLoop::_node, _retPortForOutPool, YACS::ENGINE::DynParaLoop::checkLinkPossibility(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Port::getNode(), and YACS::ENGINE::ComposedNode::isInMyDescendance().

◆ checkNoCyclePassingThrough()

void OptimizerLoop::checkNoCyclePassingThrough ( Node node)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 471 of file OptimizerLoop.cxx.

472{
473}

◆ checkTypeCode()

TypeCode * OptimizerLoop::checkTypeCode ( TypeCode tc,
const char *  portName 
)
private

Definition at line 744 of file OptimizerLoop.cxx.

745{
746 if (tc == NULL) {
747 ostringstream errorMsg;
748 errorMsg << "The algorithm specified for OptimizerLoop node \"" << getName() <<
749 "\" provided an invalid type for port \"" << portName << "\"";
750 throw Exception(errorMsg.str());
751 }
752 return tc;
753}
std::string getName() const

References YACS::ENGINE::ComposedNode::getName().

Referenced by setAlgorithm().

◆ cleanInterceptors()

void OptimizerLoop::cleanInterceptors ( )
protected

Definition at line 548 of file OptimizerLoop.cxx.

549{
550 // At this point all garanties taken let's clean all.
551 map<InputPort *,vector<InputPort *> >::iterator iter=_interceptors.begin();
552 for(;iter!=_interceptors.end();iter++)
553 for(vector<InputPort *>::iterator iter2=(*iter).second.begin();iter2!=(*iter).second.end();iter2++)
554 delete (*iter2);
555 _interceptors.clear();
556 for(vector<AnyInputPort *>::iterator iter3=_interceptorsForOutPool.begin();iter3!=_interceptorsForOutPool.end();iter3++)
557 delete (*iter3);
559}
std::map< InputPort *, std::vector< InputPort * > > _interceptors
outputports interceptors leaving current scope.
std::vector< AnyInputPort * > _interceptorsForOutPool

References _interceptors, and _interceptorsForOutPool.

Referenced by init(), and ~OptimizerLoop().

◆ edGetAlgoInitPort()

InputPort * YACS::ENGINE::OptimizerLoop::edGetAlgoInitPort ( )
inline

◆ edGetAlgoResultPort()

OutputPort * YACS::ENGINE::OptimizerLoop::edGetAlgoResultPort ( )
inline

Definition at line 87 of file OptimizerLoop.hxx.

87{ return &_algoResultPort; }

Referenced by YACS::HMI::EditionOptimizerLoop::update().

◆ edGetPortForOutPool()

InputPort * YACS::ENGINE::OptimizerLoop::edGetPortForOutPool ( )
inline

◆ exUpdateState()

void OptimizerLoop::exUpdateState ( )
virtual

Update the node state.

Note
: Update the '_state' attribute. Typically called by 'this->_inGate' when 'this->_inGate' is ready.

Called by InGate::exNotifyFromPrecursor

Reimplemented from YACS::ENGINE::Node.

Definition at line 161 of file OptimizerLoop.cxx.

162{
164 return;
167 try
168 {
169 if(_inGate.exIsReady())
170 {
172 // Force termination in case the previous algorithm did not finish properly (manual stop)
173 _alg->finishProxy();
175
176 // Initialize and launch the algorithm
178 if (_alg->hasError()) {
179 string error = _alg->getError();
180 _alg->finishProxy();
181 throw Exception(error);
182 }
183
184 //internal graph update
185 int i;
186 int nbOfBr=_nbOfBranches->getIntValue();
187 _alg->setNbOfBranches(nbOfBr);
188
189 _alg->startProxy();
190 if (_alg->hasError()) {
191 string error = _alg->getError();
192 _alg->finishProxy();
193 throw Exception(error);
194 }
195
196 if(nbOfBr==0)
197 {
198 // A number of branches of 0 is acceptable if there are no output ports
199 // leaving OptimizerLoop
200 bool normal = getAllOutPortsLeavingCurrentScope().empty();
202 "OptimizerLoop has no branch to run the internal node(s)");
203 return;
204 }
205 _execNodes.resize(nbOfBr);
206 _execIds.resize(nbOfBr);
207 if(_initNode)
208 {
209 _execInitNodes.resize(nbOfBr);
210 _initNodeUpdated.resize(nbOfBr);
211 for(i=0;i<nbOfBr;i++)
212 _initNodeUpdated[i]=false;
213 }
215 if (_finalizeNode)
216 _execFinalizeNodes.resize(nbOfBr);
217 vector<Node *> origNodes;
218 origNodes.push_back(_initNode);
219 origNodes.push_back(_node);
220 origNodes.push_back(_finalizeNode);
221 for(i=0;i<nbOfBr;i++)
222 {
224 vector<Node *> clonedNodes = cloneAndPlaceNodesCoherently(origNodes);
225 if(_initNode)
226 _execInitNodes[i] = clonedNodes[0];
227 _execNodes[i] = clonedNodes[1];
228 if(_finalizeNode)
229 _execFinalizeNodes[i] = clonedNodes[2];
231 }
232 initInterceptors(nbOfBr);
233 int id;
234 unsigned char priority;
236 if(!val)
237 {
238 // It is acceptable to have no sample to launch if there are no output ports
239 // leaving OptimizerLoop
240 std::set<OutPort *> setOutPort = getAllOutPortsLeavingCurrentScope();
241 // Special in the special
242 // We do not check algoResult
243 setOutPort.erase(&_algoResultPort);
244 bool normal = setOutPort.empty();
246 string("The algorithm of OptimizerLoop with name ") + _name +
247 " returns no sample to launch");
248 _alg->finishProxy();
249 return;
250 }
251 launchMaxOfSamples(true);
252 }
253 }
254 catch (const exception & e)
255 {
257 string("An error happened in the control algorithm of OptimizerLoop \"") + _name +
258 "\": " + e.what());
259 }
260}
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const
List all output ports of children nodes that are linked to out of scope input ports.
std::vector< Node * > _execNodes
Definition: DynParaLoop.hxx:58
std::vector< Node * > cloneAndPlaceNodesCoherently(const std::vector< Node * > &origNodes)
Clone nodes and make their placement consistent with the placement of the original ones.
std::vector< int > _execIds
Definition: DynParaLoop.hxx:54
std::vector< Node * > _execFinalizeNodes
Definition: DynParaLoop.hxx:60
void prepareInputsFromOutOfScope(int branchNb)
std::vector< Node * > _execInitNodes
Definition: DynParaLoop.hxx:59
bool exIsReady() const
Definition: InGate.cxx:126
std::string _name
Definition: Node.hxx:89
InGate _inGate
Definition: Node.hxx:86
void setState(YACS::StatesForNode theState)
Sets the given state for node.
Definition: Node.cxx:652
YACS::StatesForNode _state
Definition: Node.hxx:91
virtual void initializeProxy(const Any *input)
virtual const std::string & getError() const
virtual bool hasError() const
void setNbOfBranches(int nbOfBranches)
friend class FakeNodeForOptimizerLoop
void initInterceptors(unsigned nbOfBr)
static const int NOT_INITIALIZED_BRANCH_ID
void launchMaxOfSamples(bool first)
std::vector< bool > _initNodeUpdated
void destroyAll()
Definition: Pool.cxx:122
Any * getNextSampleWithHighestPriority(int &id, unsigned char &priority) const
Definition: Pool.cxx:204
@ TOACTIVATE
Definition: define.hxx:40
@ DISABLED
Definition: define.hxx:50

References _alg, _algoInitPort, _algoResultPort, YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::Node::_inGate, YACS::ENGINE::DynParaLoop::_initializingCounter, YACS::ENGINE::DynParaLoop::_initNode, _initNodeUpdated, _myPool, YACS::ENGINE::Node::_name, YACS::ENGINE::DynParaLoop::_nbOfBranches, YACS::ENGINE::DynParaLoop::_node, _nodeForSpecialCases, YACS::ENGINE::Node::_state, YACS::ENGINE::DynParaLoop::cloneAndPlaceNodesCoherently(), YACS::ENGINE::Pool::destroyAll(), YACS::DISABLED, YACS::ENGINE::InGate::exIsReady(), FakeNodeForOptimizerLoop, YACS::ENGINE::OptimizerAlgBase::finishProxy(), YACS::ENGINE::ComposedNode::getAllOutPortsLeavingCurrentScope(), YACS::ENGINE::OptimizerAlgBase::getError(), YACS::ENGINE::Pool::getNextSampleWithHighestPriority(), YACS::ENGINE::AnyInputPort::getValue(), YACS::ENGINE::OptimizerAlgBase::hasError(), yacsorb.CORBAEngineTest::i, YACS::ENGINE::OptimizerAlgBase::initializeProxy(), initInterceptors(), launchMaxOfSamples(), NOT_INITIALIZED_BRANCH_ID, YACS::ENGINE::DynParaLoop::prepareInputsFromOutOfScope(), YACS::ENGINE::OptimizerAlgBase::setNbOfBranches(), YACS::ENGINE::Node::setState(), YACS::ENGINE::OptimizerAlgBase::startProxy(), and YACS::TOACTIVATE.

◆ finalize()

YACS::Event OptimizerLoop::finalize ( )

Definition at line 411 of file OptimizerLoop.cxx.

412{
413 //update internal node (definition node) state
414 if (_node)
415 {
417 ComposedNode* compNode = dynamic_cast<ComposedNode*>(_node);
418 if (compNode)
419 {
420 std::list<Node *> aChldn = compNode->getAllRecursiveConstituents();
421 std::list<Node *>::iterator iter=aChldn.begin();
422 for(;iter!=aChldn.end();iter++)
423 (*iter)->setState(YACS::DONE);
424 }
425 }
427 _alg->finishProxy();
428 if (_finalizeNode == NULL)
429 {
430 // No finalize node, we just finish OptimizerLoop at the end of exec nodes execution
432 return YACS::FINISH;
433 }
434 else
435 {
436 // Run the finalize nodes, the OptimizerLoop will be done only when they all finish
437 _unfinishedCounter = 0; // This counter indicates how many branches are not finished
438 for (int i=0 ; i<_nbOfBranches->getIntValue() ; i++)
440 {
441 DEBTRACE("Launching finalize node for branch " << i)
442 _execFinalizeNodes[i]->exUpdateState();
444 }
445 else
446 // There should not be any running branch at this point
448 return YACS::NOEVENT;
449 }
450}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
virtual void put(const void *data)
virtual std::list< Node * > getAllRecursiveConstituents()
Idem getAllRecursiveNodes, but this node is NOT included.
virtual Any * getAlgoResultProxy()
static const int NOT_RUNNING_BRANCH_ID
@ NOEVENT
Definition: define.hxx:57
@ FINISH
Definition: define.hxx:59
@ DONE
Definition: define.hxx:43

References _alg, _algoResultPort, YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::DynParaLoop::_nbOfBranches, YACS::ENGINE::DynParaLoop::_node, YACS::ENGINE::DynParaLoop::_unfinishedCounter, DEBTRACE, YACS::DONE, YACS::FINISH, YACS::ENGINE::OptimizerAlgBase::finishProxy(), YACS::ENGINE::OptimizerAlgBase::getAlgoResultProxy(), YACS::ENGINE::ComposedNode::getAllRecursiveConstituents(), yacsorb.CORBAEngineTest::i, YACS::NOEVENT, NOT_INITIALIZED_BRANCH_ID, NOT_RUNNING_BRANCH_ID, YACS::ENGINE::AnyOutputPort::put(), YACS::ENGINE::Node::setState(), and YASSERT.

Referenced by updateStateOnFinishedEventFrom().

◆ getAlgLib()

std::string OptimizerLoop::getAlgLib ( ) const
virtual

Return the name of the algorithm library.

Definition at line 793 of file OptimizerLoop.cxx.

794{
795 return _alglib;
796}

References _alglib.

Referenced by YACS::HMI::EditionOptimizerLoop::onModifyLib(), YACS::HMI::EditionOptimizerLoop::update(), and YACS::ENGINE::VisitorSaveSchema::visitOptimizerLoop().

◆ getInputPort()

InputPort * OptimizerLoop::getInputPort ( const std::string &  name) const
virtual

Get an input port given its name.

Contrary to YACS::ENGINE::ComposedNode::getOutputPort, this method is NOT recursive and so the leaf of type ElementaryNode aggregating this InputPort is directly invoked.

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 267 of file OptimizerLoop.cxx.

268{
269 if (name == NAME_OF_ALGO_INIT_PORT)
270 return (InputPort *)&_algoInitPort;
271 else if (name == NAME_OF_OUT_POOL_INPUT)
272 return (InputPort *)&_retPortForOutPool;
273 else
274 return DynParaLoop::getInputPort(name);
275}
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
Base class for Input Ports.
Definition: InputPort.hxx:44

References _algoInitPort, _retPortForOutPool, YACS::ENGINE::DynParaLoop::getInputPort(), NAME_OF_ALGO_INIT_PORT, and NAME_OF_OUT_POOL_INPUT.

◆ getLocalInputPorts()

std::list< InputPort * > OptimizerLoop::getLocalInputPorts ( ) const
virtual

redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 285 of file OptimizerLoop.cxx.

286{
287 list<InputPort *> ret=DynParaLoop::getLocalInputPorts();
288 ret.push_back((InputPort *)&_algoInitPort);
289 ret.push_back((InputPort *)&_retPortForOutPool);
290 return ret;
291}
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

References _algoInitPort, _retPortForOutPool, and YACS::ENGINE::DynParaLoop::getLocalInputPorts().

◆ getLocalOutputPorts()

std::list< OutputPort * > OptimizerLoop::getLocalOutputPorts ( ) const
virtual

redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 827 of file OptimizerLoop.cxx.

828{
829 list<OutputPort *> ret = DynParaLoop::getLocalOutputPorts();
830 ret.push_front((OutputPort *)&_algoResultPort);
831 return ret;
832}
std::list< OutputPort * > getLocalOutputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself

References _algoResultPort, and YACS::ENGINE::DynParaLoop::getLocalOutputPorts().

◆ getNumberOfInputPorts()

int OptimizerLoop::getNumberOfInputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 262 of file OptimizerLoop.cxx.

263{
265}
int getNumberOfInputPorts() const

References YACS::ENGINE::DynParaLoop::getNumberOfInputPorts().

◆ getNumberOfOutputPorts()

int OptimizerLoop::getNumberOfOutputPorts ( ) const
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 815 of file OptimizerLoop.cxx.

816{
818}
int getNumberOfOutputPorts() const

References YACS::ENGINE::DynParaLoop::getNumberOfOutputPorts().

◆ getOutPort()

OutPort * OptimizerLoop::getOutPort ( const std::string &  name) const
virtual
Note
: Contrary to getOutputPort method, this method returns the output port at highest level, possible. That is to say in some ComposedNode, like ForEachLoop or Switch, an outport inside 'this' is seen differently than the true outport.

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 834 of file OptimizerLoop.cxx.

835{
836 return (name == NAME_OF_ALGO_RESULT_PORT) ? (OutPort *)&_algoResultPort :
838}
OutPort * getOutPort(const std::string &name) const

References _algoResultPort, YACS::ENGINE::DynParaLoop::getOutPort(), and NAME_OF_ALGO_RESULT_PORT.

Referenced by OptimizerLoop().

◆ getOutputPort()

OutputPort * OptimizerLoop::getOutputPort ( const std::string &  name) const
virtual

Get an output port given its name.

Contrary to YACS::ENGINE::ComposedNode::getInputPort, this method is recursive and go down hierarchy step by step to complete its work.

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 841 of file OptimizerLoop.cxx.

842{
845}
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.

References _algoResultPort, YACS::ENGINE::DynParaLoop::getOutputPort(), and NAME_OF_ALGO_RESULT_PORT.

Referenced by initInterceptors().

◆ getReadyTasks()

void OptimizerLoop::getReadyTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Node.

Definition at line 297 of file OptimizerLoop.cxx.

298{
299 if(!_node)
300 return;
302 {
304 {
306 return ;
307 }
308 vector<Node *>::iterator iter;
309 for (iter=_execNodes.begin() ; iter!=_execNodes.end() ; iter++)
310 (*iter)->getReadyTasks(tasks);
311 for (iter=_execInitNodes.begin() ; iter!=_execInitNodes.end() ; iter++)
312 (*iter)->getReadyTasks(tasks);
313 for (iter=_execFinalizeNodes.begin() ; iter!=_execFinalizeNodes.end() ; iter++)
314 (*iter)->getReadyTasks(tasks);
315 }
316}
void getReadyTasks(std::vector< Task * > &tasks)
@ ACTIVATED
Definition: define.hxx:41

References YACS::ENGINE::DynParaLoop::_execFinalizeNodes, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_node, _nodeForSpecialCases, YACS::ENGINE::Node::_state, YACS::ACTIVATED, YACS::ENGINE::ElementaryNode::getReadyTasks(), and YACS::TOACTIVATE.

◆ getSetOfInputPort()

std::list< InputPort * > OptimizerLoop::getSetOfInputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 277 of file OptimizerLoop.cxx.

278{
279 list<InputPort *> ret=DynParaLoop::getSetOfInputPort();
280 ret.push_back((InputPort *)&_algoInitPort);
281 ret.push_back((InputPort *)&_retPortForOutPool);
282 return ret;
283}
std::list< InputPort * > getSetOfInputPort() const

References _algoInitPort, _retPortForOutPool, and YACS::ENGINE::DynParaLoop::getSetOfInputPort().

◆ getSetOfOutputPort()

std::list< OutputPort * > OptimizerLoop::getSetOfOutputPort ( ) const
virtual

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 820 of file OptimizerLoop.cxx.

821{
822 list<OutputPort *> ret = DynParaLoop::getSetOfOutputPort();
823 ret.push_back((OutputPort *)&_algoResultPort);
824 return ret;
825}
std::list< OutputPort * > getSetOfOutputPort() const

References _algoResultPort, and YACS::ENGINE::DynParaLoop::getSetOfOutputPort().

◆ getSymbol()

virtual std::string YACS::ENGINE::OptimizerLoop::getSymbol ( ) const
inlinevirtual

◆ init()

void OptimizerLoop::init ( bool  start = true)
virtual

◆ initInterceptors()

void OptimizerLoop::initInterceptors ( unsigned  nbOfBr)
protected

Perform initialization of interceptors. WARNING _execNodes have to be created before.

Definition at line 621 of file OptimizerLoop.cxx.

622{
623 //For all classical outputports leaving 'this'
624 set<OutPort *> portsToIntercept=getAllOutPortsLeavingCurrentScope();
625 portsToIntercept.erase(&_algoResultPort);
626 for(set<OutPort *>::iterator iter=portsToIntercept.begin();iter!=portsToIntercept.end();iter++)
627 {
628 OutputPort *portC=(OutputPort *)(*iter);//Warrantied by OptimizerLoop::buildDelegateOf
629 const set<InputPort *>& links=portC->getSetOfPhyLinks();
630 for(set<InputPort *>::const_iterator iter2=links.begin();iter2!=links.end();iter2++)
631 {
632#ifdef NOCOVARIANT
633 InputPort *reprCur=dynamic_cast<InputPort *>((*iter2)->getPublicRepresentant());
634#else
635 InputPort *reprCur=(*iter2)->getPublicRepresentant();
636#endif
637 if(!isInMyDescendance(reprCur->getNode()))
638 {//here we've got an out of scope link : Let's intercept it
639 if(_interceptors.find(reprCur)==_interceptors.end())
640 {
641 _interceptors[reprCur].resize(nbOfBr);
642 for(unsigned i=0;i<nbOfBr;i++)
643 {
645 InputPort *clone=reprCur->clone(0);
646 _interceptors[reprCur][i]=clone;
647 portExecC->edAddInputPort(clone);
648 }
649 }
650 else
651 {
652 for(unsigned i=0;i<nbOfBr;i++)
653 {
655 portExecC->edAddInputPort(_interceptors[reprCur][i]);
656 }
657 }
658 }
659 }
660 }
661 // For out pool
662 _interceptorsForOutPool.resize(nbOfBr);
663 set< OutPort * > links=_retPortForOutPool.edSetOutPort();
664 for(unsigned i=0;i<nbOfBr;i++)
666 for(set<OutPort *>::iterator iter2=links.begin();iter2!=links.end();iter2++)
667 for(unsigned j=0;j<nbOfBr;j++)
668 {
669 OutPort *portExec;
670 Node *whatType=isInMyDescendance((*iter2)->getNode());
671 if(whatType==_node)
672 {
673 portExec=_execNodes[j]->getOutPort(_node->getOutPortName(*iter2));
675 }
676 else if(whatType==_initNode && whatType!=0)//This case should never happend. Useless !
677 {
678 portExec=_execInitNodes[j]->getOutPort(_node->getOutPortName(*iter2));
680 }
681 }
682}
InputPort * clone(Node *newHelder) const
virtual InputPort * clone(Node *newHelder) const =0
virtual InputPort * getPublicRepresentant()
returns the final physical port behind 'this'.
Definition: InputPort.hxx:57
Base class for all nodes.
Definition: Node.hxx:70
virtual std::string getOutPortName(const OutPort *) const =0
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
Definition: Node.cxx:131
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.
virtual bool addInPort(InPort *inPort)=0
virtual bool edAddInputPort(InputPort *phyPort)
Definition: OutputPort.cxx:75
const std::set< InputPort * > & getSetOfPhyLinks() const
Returns physical links linked to this. Contrary to edSetInPort that returns semantic links.
Definition: OutputPort.cxx:255

References _algoResultPort, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_initNode, _interceptors, _interceptorsForOutPool, YACS::ENGINE::DynParaLoop::_node, _retPortForOutPool, YACS::ENGINE::OutPort::addInPort(), YACS::ENGINE::Node::clone(), YACS::ENGINE::AnyInputPort::clone(), YACS::ENGINE::InputPort::clone(), YACS::ENGINE::OutputPort::edAddInputPort(), YACS::ENGINE::InPort::edSetOutPort(), YACS::ENGINE::ComposedNode::getAllOutPortsLeavingCurrentScope(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::Node::getOutPortName(), getOutputPort(), YACS::ENGINE::InputPort::getPublicRepresentant(), YACS::ENGINE::OutputPort::getSetOfPhyLinks(), yacsorb.CORBAEngineTest::i, and YACS::ENGINE::ComposedNode::isInMyDescendance().

Referenced by exUpdateState().

◆ isFullyBusy()

bool OptimizerLoop::isFullyBusy ( unsigned &  branchId) const
protected

Returns if a dynamic branch is available.

Parameters
branchIdOut param. Only usable if returned value is equal to false.

Definition at line 607 of file OptimizerLoop.cxx.

608{
609 bool isFinished=true;
610 unsigned i;
611 for(i=0;i<_execIds.size() && isFinished;i++)
613 if(!isFinished)
614 branchId=i-1;
615 return isFinished;
616}

References YACS::ENGINE::DynParaLoop::_execIds, yacsorb.CORBAEngineTest::i, YACS::ENGINE::ComposedNode::isFinished(), NOT_INITIALIZED_BRANCH_ID, and NOT_RUNNING_BRANCH_ID.

Referenced by launchMaxOfSamples().

◆ isFullyLazy()

bool OptimizerLoop::isFullyLazy ( ) const
protected

Definition at line 595 of file OptimizerLoop.cxx.

596{
597 bool isLazy=true;
598 for(unsigned i=0;i<_execIds.size() && isLazy;i++)
600 return isLazy;
601}

References YACS::ENGINE::DynParaLoop::_execIds, yacsorb.CORBAEngineTest::i, NOT_INITIALIZED_BRANCH_ID, and NOT_RUNNING_BRANCH_ID.

Referenced by updateStateOnFinishedEventFrom().

◆ launchMaxOfSamples()

void OptimizerLoop::launchMaxOfSamples ( bool  first)
protected

Definition at line 561 of file OptimizerLoop.cxx.

562{
563 int id;
564 unsigned char priority;
565 Any *val;
566 unsigned i;
567 for (val = _myPool.getNextSampleWithHighestPriority(id, priority);
568 !isFullyBusy(i) && val;
569 val = _myPool.getNextSampleWithHighestPriority(id, priority))
570 {
572 first=true; // node is not initialized (first pass)
573 else
574 first=false; // node is initialized (second pass)
575 _execIds[i]=id;
578 {
579 putValueOnBranch(val,i,first);
580 _execInitNodes[i]->exUpdateState();
581 _initNodeUpdated[i]=true;
583 }
584 else
585 {
586 if(!first)
587 _execNodes[i]->init(first);
588 putValueOnBranch(val,i,first);
589 _execNodes[i]->exUpdateState();
591 }
592 }
593}
void putValueOnBranch(Any *val, unsigned branchId, bool first)
bool isFullyBusy(unsigned &branchId) const
void markIdAsInUse(int id)
Definition: Pool.cxx:232

References YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_execInitNodes, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_initializingCounter, YACS::ENGINE::DynParaLoop::_initNode, _initNodeUpdated, _myPool, YACS::ENGINE::DynParaLoop::_nbOfEltConsumed, YACS::ENGINE::Pool::getNextSampleWithHighestPriority(), yacsorb.CORBAEngineTest::i, isFullyBusy(), YACS::ENGINE::Pool::markIdAsInUse(), NOT_INITIALIZED_BRANCH_ID, and YACS::ENGINE::DynParaLoop::putValueOnBranch().

Referenced by exUpdateState(), and updateStateOnFinishedEventFrom().

◆ loadAlgorithm()

void OptimizerLoop::loadAlgorithm ( )
protectedvirtual

Load the algorithm from the dynamic library.

Reimplemented in YACS::ENGINE::SalomeOptimizerLoop.

Definition at line 759 of file OptimizerLoop.cxx.

760{
761 YASSERT(_alg == NULL)
762
763 if (_loader != NULL) {
764 delete _loader;
765 _loader = NULL;
766 }
767 _loader = new YACS::BASES::DynLibLoader(_alglib);
768 OptimizerAlgBaseFactory algFactory = NULL;
769
770 if (_alglib != "" && _symbol != "")
771 {
772 try
773 {
774 _errorDetails = "";
775 algFactory = (OptimizerAlgBaseFactory)_loader->getHandleOnSymbolWithName(_symbol);
776 }
777 catch (YACS::Exception& e)
778 {
779 _errorDetails = e.what();
780 modified();
781 throw;
782 }
783 }
784
785 if (algFactory != NULL)
786 _alg = algFactory(&_myPool);
787}
virtual void modified()
Sets Node in modified state and its father if it exists.
Definition: Node.cxx:805
const char * what(void) const noexcept
Definition: Exception.cxx:50
OptimizerAlgBase *(* OptimizerAlgBaseFactory)(Pool *pool)

References _alg, _alglib, YACS::ENGINE::Node::_errorDetails, _loader, _myPool, _symbol, YACS::ENGINE::Node::modified(), YACS::Exception::what(), and YASSERT.

Referenced by YACS::ENGINE::SalomeOptimizerLoop::loadAlgorithm(), and setAlgorithm().

◆ pushValueOutOfScopeForCase()

void OptimizerLoop::pushValueOutOfScopeForCase ( unsigned  branchId)
protected

Typically called when _alg has decided that convergence has been reached. In this case the links leaving the current scope are activated and filled with value of the branch specified by 'branchId' that is the branch in which the convergence has been reached.

Definition at line 688 of file OptimizerLoop.cxx.

689{
690 map<InputPort *, std::vector<InputPort *> >::iterator iter;
691 for(iter=_interceptors.begin();iter!=_interceptors.end();iter++)
692 (*iter).first->put((*iter).second[branchId]->get());
693}

References _interceptors.

Referenced by updateStateOnFinishedEventFrom().

◆ selectRunnableTasks()

void OptimizerLoop::selectRunnableTasks ( std::vector< Task * > &  tasks)
virtual

Implements YACS::ENGINE::Scheduler.

Definition at line 293 of file OptimizerLoop.cxx.

294{
295}

◆ setAlgorithm()

void OptimizerLoop::setAlgorithm ( const std::string &  alglib,
const std::string &  symbol,
bool  checkLinks = true,
Proc procForTypes = NULL 
)
virtual

Set the algorithm library name and factory name (symbol in library) to create the algorithm and change it if the node is not connected.

throw an exception if the node is connected

Definition at line 704 of file OptimizerLoop.cxx.

706{
707 if(checkLinks)
708 {
713 throw Exception("The OptimizerLoop node must be disconnected before setting the algorithm");
714 }
715
716 _symbol = symbol;
717 _alglib = alglib;
718
719 if (_alg) {
720 _alg->decrRef();
721 _alg = NULL;
722 }
723
725
726 if(_alg)
727 {
728 _alg->setProc((procForTypes == NULL) ? getProc() : procForTypes);
729
730 // Delete the values in the input ports if they were initialized
731 _retPortForOutPool.put((Any *)NULL);
732 _algoInitPort.put((Any *)NULL);
733
734 // Change the type of the ports
739 }
740
741 modified();
742}
void edSetType(TypeCode *type)
Definition: DataPort.cxx:47
static const char NAME_OF_SPLITTED_SEQ_OUT[]
Definition: DynParaLoop.hxx:67
AnyOutputPort _splittedPort
Definition: DynParaLoop.hxx:57
virtual int edGetNumberOfLinks() const
Returns number of physical backlinks NOT number of user backlinks.
Definition: InPort.cxx:45
virtual Proc * getProc()
Definition: Node.cxx:401
virtual TypeCode * getTCForInProxy() const
virtual TypeCode * getTCForAlgoInitProxy() const
virtual void setProc(Proc *proc)
virtual TypeCode * getTCForAlgoResultProxy() const
virtual TypeCode * getTCForOutProxy() const
TypeCode * checkTypeCode(TypeCode *tc, const char *portName)
virtual void loadAlgorithm()
Load the algorithm from the dynamic library.
virtual int edGetNumberOfOutLinks() const
Definition: OutPort.cxx:50

References _alg, _alglib, _algoInitPort, _algoResultPort, _retPortForOutPool, YACS::ENGINE::DynParaLoop::_splittedPort, _symbol, checkTypeCode(), YACS::ENGINE::RefCounter::decrRef(), YACS::ENGINE::InPort::edGetNumberOfLinks(), YACS::ENGINE::OutPort::edGetNumberOfOutLinks(), YACS::ENGINE::DataPort::edSetType(), YACS::ENGINE::Node::getProc(), YACS::ENGINE::OptimizerAlgBase::getTCForAlgoInitProxy(), YACS::ENGINE::OptimizerAlgBase::getTCForAlgoResultProxy(), YACS::ENGINE::OptimizerAlgBase::getTCForInProxy(), YACS::ENGINE::OptimizerAlgBase::getTCForOutProxy(), loadAlgorithm(), YACS::ENGINE::Node::modified(), NAME_OF_ALGO_INIT_PORT, NAME_OF_ALGO_RESULT_PORT, NAME_OF_OUT_POOL_INPUT, YACS::ENGINE::DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT, YACS::ENGINE::AnyInputPort::put(), and YACS::ENGINE::OptimizerAlgBase::setProc().

Referenced by YACS::HMI::CommandSetAlgo::localExecute(), YACS::HMI::CommandSetAlgo::localReverse(), OptimizerLoop(), YACS::ENGINE::SalomeOptimizerLoop::SalomeOptimizerLoop(), YACS::ENGINE::SalomeOptimizerLoop::simpleClone(), and simpleClone().

◆ simpleClone()

Node * OptimizerLoop::simpleClone ( ComposedNode father,
bool  editionOnly = true 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Reimplemented in YACS::ENGINE::SalomeOptimizerLoop.

Definition at line 137 of file OptimizerLoop.cxx.

138{
139 OptimizerLoop* ol=new OptimizerLoop(*this,father,editionOnly);
140 // TODO: Remove this const_cast (find a better design to get the type codes from the original node)
141 Proc * procForTypes = ol->getProc();
142 if (procForTypes == NULL) {
143 const Proc * origProc = getProc();
144 procForTypes = const_cast<Proc *>(origProc);
145 }
146 ol->setAlgorithm(_alglib, _symbol, false, procForTypes);
147 return ol;
148}
class to build optimization loops
OptimizerLoop(const std::string &name, const std::string &algLibWthOutExt, const std::string &symbolNameToOptimizerAlgBaseInstanceFactory, bool algInitOnFile, bool initAlgo=true, Proc *procForTypes=NULL)
Base class for all schema objects.
Definition: Proc.hxx:44

References _alglib, _symbol, YACS::ENGINE::Node::getProc(), OptimizerLoop(), and setAlgorithm().

◆ typeName()

virtual std::string YACS::ENGINE::OptimizerLoop::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ComposedNode.

Reimplemented in YACS::ENGINE::SalomeOptimizerLoop.

Definition at line 101 of file OptimizerLoop.hxx.

101{return "YACS__ENGINE__OptimizerLoop";}

◆ updateStateOnFailedEventFrom()

YACS::Event OptimizerLoop::updateStateOnFailedEventFrom ( Node node,
const Executor execInst 
)
protectedvirtual

Method used to notify the node that a child node has failed.

Notify the slave thread of the error, update the current state and return the change state

Parameters
node: the child node that has failed
Returns
the state change

Reimplemented from YACS::ENGINE::DynParaLoop.

Definition at line 460 of file OptimizerLoop.cxx.

461{
462 DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom " << node->getName());
463 _alg->setError(string("Error during the execution of YACS node ") + node->getName() +
464 ": " + node->getErrorReport());
465 _alg->finishProxy();
467 DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom: returned from error notification.");
468 return DynParaLoop::updateStateOnFailedEventFrom(node,execInst);
469}
virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
Method used to notify the node that a child node has failed.
const std::string & getName() const
Definition: Node.hxx:125
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
Definition: Node.cxx:755
virtual void setError(const std::string &message)

References _alg, _myPool, DEBTRACE, YACS::ENGINE::Pool::destroyAll(), YACS::ENGINE::OptimizerAlgBase::finishProxy(), YACS::ENGINE::Node::getErrorReport(), YACS::ENGINE::Node::getName(), YACS::ENGINE::OptimizerAlgBase::setError(), and YACS::ENGINE::DynParaLoop::updateStateOnFailedEventFrom().

◆ updateStateOnFinishedEventFrom()

YACS::Event OptimizerLoop::updateStateOnFinishedEventFrom ( Node node)
virtual

Implements YACS::ENGINE::ComposedNode.

Definition at line 318 of file OptimizerLoop.cxx.

319{
320 if (getState() == YACS::FAILED)
321 {
322 // This happens when a valid computation on a branch finishes after an error on another branch.
323 // In this case we just ignore the new result because the algorithm has already been terminated.
324 return YACS::NOEVENT;
325 }
326 unsigned int id;
327 switch(getIdentityOfNotifyerNode(node,id))
328 {
329 case INIT_NODE:
330 {
331 _execNodes[id]->exUpdateState();
335 break;
336 }
337 case WORK_NODE:
338 {
340 { //This case happens when alg has reached its convergence whereas other calculations still compute
342 if(!isFullyLazy())
343 return YACS::NOEVENT;
344 else
345 return finalize();
346 }
350 if (_alg->hasError()) {
351 _errorDetails = string("An error happened in the control algorithm of optimizer loop: ") +
352 _alg->getError();
353 _alg->finishProxy();
355 return YACS::ABORT;
356 }
357
359 if(_myPool.empty())
360 {
363 if(!isFullyLazy())
364 {// This case happens when the hand is returned to continue, whereas some other are working in parallel for nothing.
366 return YACS::NOEVENT;
367 }
368 return finalize();
369 }
371 int newId;
372 unsigned char priority;
373 Any *val=_myPool.getNextSampleWithHighestPriority(newId, priority);
374 if(!val)
375 {
376 bool isFinished=true;
377 for(int i=0;i<_execIds.size() && isFinished;i++)
379 if(isFinished)
380 {
381 std::cerr <<"OptimizerLoop::updateStateOnFinishedEventFrom: Alg has not inserted more cases whereas last element has been calculated !" << std::endl;
384 _alg->finishProxy();
385 return YACS::FINISH;
386 }
387 return YACS::NOEVENT;
388 }
389 launchMaxOfSamples(false);
390 break;
391 }
392 case FINALIZE_NODE:
393 {
395 if (_unfinishedCounter == 0)
396 {
399 return YACS::FINISH;
400 }
401 else
402 return YACS::NOEVENT;
403 break;
404 }
405 default:
406 YASSERT(false);
407 }
408 return YACS::NOEVENT;
409}
TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned &id)
virtual YACS::StatesForNode getState() const
Definition: Node.hxx:118
virtual void exForwardFailed()
Definition: Node.cxx:378
void pushValueOutOfScopeForCase(unsigned branchId)
void destroyCurrentCase()
Definition: Pool.cxx:127
bool empty() const
Definition: Pool.cxx:246
void setCurrentId(int id)
Definition: Pool.cxx:159
void putOutSampleAt(int id, Any *outValue)
Definition: Pool.cxx:180
@ ABORT
Definition: define.hxx:60
@ FAILED
Definition: define.hxx:51
@ ERROR
Definition: define.hxx:52

References _alg, _convergenceReachedWithOtherCalc, YACS::ENGINE::Node::_errorDetails, YACS::ENGINE::DynParaLoop::_execIds, YACS::ENGINE::DynParaLoop::_execNodes, YACS::ENGINE::DynParaLoop::_finalizeNode, YACS::ENGINE::DynParaLoop::_initializingCounter, YACS::ENGINE::DynParaLoop::_initNode, _interceptorsForOutPool, _myPool, YACS::ENGINE::DynParaLoop::_nbOfEltConsumed, YACS::ENGINE::DynParaLoop::_unfinishedCounter, YACS::ABORT, YACS::ENGINE::Pool::destroyCurrentCase(), YACS::DONE, YACS::ENGINE::Pool::empty(), YACS::ERROR, YACS::ENGINE::Node::exForwardFailed(), YACS::FAILED, finalize(), YACS::ENGINE::DynParaLoop::FINALIZE_NODE, YACS::FINISH, YACS::ENGINE::OptimizerAlgBase::finishProxy(), YACS::ENGINE::OptimizerAlgBase::getError(), YACS::ENGINE::DynParaLoop::getIdentityOfNotifyerNode(), YACS::ENGINE::Pool::getNextSampleWithHighestPriority(), YACS::ENGINE::Node::getState(), YACS::ENGINE::OptimizerAlgBase::hasError(), yacsorb.CORBAEngineTest::i, YACS::ENGINE::DynParaLoop::INIT_NODE, YACS::ENGINE::ComposedNode::isFinished(), isFullyLazy(), launchMaxOfSamples(), YACS::NOEVENT, NOT_INITIALIZED_BRANCH_ID, NOT_RUNNING_BRANCH_ID, pushValueOutOfScopeForCase(), YACS::ENGINE::Pool::putOutSampleAt(), YACS::ENGINE::Pool::setCurrentId(), YACS::ENGINE::Node::setState(), YACS::ENGINE::OptimizerAlgBase::takeDecisionProxy(), YACS::ENGINE::DynParaLoop::WORK_NODE, and YASSERT.

Friends And Related Function Documentation

◆ FakeNodeForOptimizerLoop

friend class FakeNodeForOptimizerLoop
friend

Definition at line 58 of file OptimizerLoop.hxx.

Referenced by exUpdateState().

Member Data Documentation

◆ _alg

◆ _algInitOnFile

bool YACS::ENGINE::OptimizerLoop::_algInitOnFile
protected

Definition at line 62 of file OptimizerLoop.hxx.

◆ _alglib

◆ _algoInitPort

AnyInputPort YACS::ENGINE::OptimizerLoop::_algoInitPort
protected

◆ _algoResultPort

◆ _convergenceReachedWithOtherCalc

bool YACS::ENGINE::OptimizerLoop::_convergenceReachedWithOtherCalc
protected

Definition at line 70 of file OptimizerLoop.hxx.

Referenced by init(), and updateStateOnFinishedEventFrom().

◆ _initNodeUpdated

std::vector<bool> YACS::ENGINE::OptimizerLoop::_initNodeUpdated
protected

Definition at line 69 of file OptimizerLoop.hxx.

Referenced by exUpdateState(), and launchMaxOfSamples().

◆ _interceptors

std::map<InputPort *, std::vector<InputPort *> > YACS::ENGINE::OptimizerLoop::_interceptors
protected

outputports interceptors leaving current scope.

Definition at line 74 of file OptimizerLoop.hxx.

Referenced by cleanInterceptors(), initInterceptors(), and pushValueOutOfScopeForCase().

◆ _interceptorsForOutPool

std::vector<AnyInputPort *> YACS::ENGINE::OptimizerLoop::_interceptorsForOutPool
protected

◆ _loader

::YACS::BASES::DynLibLoader* YACS::ENGINE::OptimizerLoop::_loader
protected

Definition at line 66 of file OptimizerLoop.hxx.

Referenced by loadAlgorithm(), and ~OptimizerLoop().

◆ _myPool

◆ _nodeForSpecialCases

FakeNodeForOptimizerLoop* YACS::ENGINE::OptimizerLoop::_nodeForSpecialCases
protected

Definition at line 71 of file OptimizerLoop.hxx.

Referenced by exUpdateState(), getReadyTasks(), and ~OptimizerLoop().

◆ _retPortForOutPool

◆ _symbol

◆ NAME_OF_ALGO_INIT_PORT

const char OptimizerLoop::NAME_OF_ALGO_INIT_PORT = "algoInit"
staticprotected

Definition at line 136 of file OptimizerLoop.hxx.

Referenced by getInputPort(), and setAlgorithm().

◆ NAME_OF_ALGO_RESULT_PORT

const char OptimizerLoop::NAME_OF_ALGO_RESULT_PORT = "algoResults"
staticprotected

Definition at line 138 of file OptimizerLoop.hxx.

Referenced by getOutPort(), getOutputPort(), and setAlgorithm().

◆ NAME_OF_OUT_POOL_INPUT

const char OptimizerLoop::NAME_OF_OUT_POOL_INPUT = "evalResults"
staticprotected

Definition at line 137 of file OptimizerLoop.hxx.

Referenced by getInputPort(), and setAlgorithm().

◆ NOT_INITIALIZED_BRANCH_ID

const int OptimizerLoop::NOT_INITIALIZED_BRANCH_ID =-1973
staticprotected

◆ NOT_RUNNING_BRANCH_ID

const int OptimizerLoop::NOT_RUNNING_BRANCH_ID =-1973012217
staticprotected

The documentation for this class was generated from the following files: