43 :
ElementaryNode(NAME), _loop(loop), _normal(normal), _message(message)
50 :
ElementaryNode(other), _loop(0), _normal(other._normal), _message(other._message)
99 const std::string& symbolNameToOptimizerAlgBaseInstanceFactory,
100 bool algInitOnFile,
bool initAlgo,
Proc * procForTypes):
102 _algoInitPort(NAME_OF_ALGO_INIT_PORT, this,
Runtime::_tc_string, true),
103 _loader(NULL),_alg(0),_convergenceReachedWithOtherCalc(false),
104 _retPortForOutPool(NAME_OF_OUT_POOL_INPUT,this,
Runtime::_tc_string),
105 _nodeForSpecialCases(0), _algoResultPort(NAME_OF_ALGO_RESULT_PORT, this,
Runtime::_tc_string)
110 setAlgorithm(algLibWthOutExt,symbolNameToOptimizerAlgBaseInstanceFactory, procForTypes);
114 DynParaLoop(other,father,editionOnly),_algInitOnFile(other._algInitOnFile),_alglib(other._alglib),
115 _convergenceReachedWithOtherCalc(false),_loader(NULL),_alg(0),_algoInitPort(other._algoInitPort,this),
116 _retPortForOutPool(other._retPortForOutPool,this),_nodeForSpecialCases(0),
117 _algoResultPort(other._algoResultPort, this)
123 for(set<OutPort *>::iterator iter=fromPortsToReproduce.begin();iter!=fromPortsToReproduce.end();iter++)
142 if (procForTypes == NULL) {
144 procForTypes =
const_cast<Proc *
>(origProc);
202 "OptimizerLoop has no branch to run the internal node(s)");
211 for(
i=0;
i<nbOfBr;
i++)
217 vector<Node *> origNodes;
219 origNodes.push_back(
_node);
221 for(
i=0;
i<nbOfBr;
i++)
234 unsigned char priority;
244 bool normal = setOutPort.empty();
246 string(
"The algorithm of OptimizerLoop with name ") +
_name +
247 " returns no sample to launch");
254 catch (
const exception & e)
257 string(
"An error happened in the control algorithm of OptimizerLoop \"") +
_name +
308 vector<Node *>::iterator iter;
310 (*iter)->getReadyTasks(tasks);
312 (*iter)->getReadyTasks(tasks);
314 (*iter)->getReadyTasks(tasks);
351 _errorDetails = string(
"An error happened in the control algorithm of optimizer loop: ") +
372 unsigned char priority;
381 std::cerr <<
"OptimizerLoop::updateStateOnFinishedEventFrom: Alg has not inserted more cases whereas last element has been calculated !" << std::endl;
421 std::list<Node *>::iterator iter=aChldn.begin();
422 for(;iter!=aChldn.end();iter++)
441 DEBTRACE(
"Launching finalize node for branch " <<
i)
462 DEBTRACE(
"OptimizerLoop::updateStateOnFailedEventFrom " << node->
getName());
467 DEBTRACE(
"OptimizerLoop::updateStateOnFailedEventFrom: returned from error notification.");
480 std::string linkName(
"(");
482 throw Exception(std::string(
"Illegal OptimizerLoop link: \
483 The 'evalResults' port must be linked within the scope of the loop.")
493 std::string linkName(
"(");
494 linkName += port.first->getName()+
" to "+finalTarget->
getName()+
")";
495 throw Exception(std::string(
"Illegal OptimizerLoop link: \
496 Only the algorithm result port can be linked to a port outside the scope of the loop.")
500 string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
502 throw Exception(
"OptimizerLoop::buildDelegateOf : not implemented for DS because not specified ");
507 std::vector<OutPort *>& fwCross,
526 InPort *end,
const std::list<ComposedNode *>& pointsOfViewEnd)
529 std::string linkName(
"(");
535 throw Exception(std::string(
"Illegal OptimizerLoop link.") + linkName);
540 throw Exception(std::string(
"Illegal OptimizerLoop link: \
541 The 'algoResult' port can't be linked within the scope of the loop.") + linkName);
544 throw Exception(std::string(
"Illegal OptimizerLoop link: \
545 The 'evalResults' port can only be linked to the working node.") + linkName);
551 map<InputPort *,vector<InputPort *> >::iterator iter=
_interceptors.begin();
553 for(vector<InputPort *>::iterator iter2=(*iter).second.begin();iter2!=(*iter).second.end();iter2++)
564 unsigned char priority;
626 for(set<OutPort *>::iterator iter=portsToIntercept.begin();iter!=portsToIntercept.end();iter++)
630 for(set<InputPort *>::const_iterator iter2=links.begin();iter2!=links.end();iter2++)
642 for(
unsigned i=0;
i<nbOfBr;
i++)
652 for(
unsigned i=0;
i<nbOfBr;
i++)
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++)
676 else if(whatType==
_initNode && whatType!=0)
690 map<InputPort *, std::vector<InputPort *> >::iterator iter;
692 (*iter).first->put((*iter).second[branchId]->get());
705 bool checkLinks,
Proc * procForTypes)
713 throw Exception(
"The OptimizerLoop node must be disconnected before setting the algorithm");
747 ostringstream errorMsg;
748 errorMsg <<
"The algorithm specified for OptimizerLoop node \"" <<
getName() <<
749 "\" provided an invalid type for port \"" << portName <<
"\"";
785 if (algFactory != NULL)
804 DEBTRACE(
"OptimizerLoop::checkBasicConsistency");
806 throw Exception(
"No library specified for the OptimizerLoop control algorithm");
808 throw Exception(
"No symbol specified for the OptimizerLoop control algorithm");
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
virtual void put(const void *data)
: Interface for management of storage of data formated dynamically in its TypeCode....
Base class for all composed nodes.
std::string getName() const
void solveObviousOrDelegateCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
virtual std::list< Node * > getAllRecursiveConstituents()
Idem getAllRecursiveNodes, but this node is NOT included.
std::set< OutPort * > getAllOutPortsLeavingCurrentScope() const
List all output ports of children nodes that are linked to out of scope input ports.
std::string getPortName(const PORT *port) const
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
void edSetType(TypeCode *type)
std::string getName() const
Base class for dynamically (fully or semifully) built graphs.
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
std::list< OutputPort * > getLocalOutputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
int getNumberOfInputPorts() const
virtual void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
std::unique_ptr< NbBranchesAbstract > _nbOfBranches
std::list< OutputPort * > getSetOfOutputPort() const
std::vector< Node * > _execNodes
static const char NAME_OF_SPLITTED_SEQ_OUT[]
std::vector< Node * > cloneAndPlaceNodesCoherently(const std::vector< Node * > &origNodes)
Clone nodes and make their placement consistent with the placement of the original ones.
void buildDelegateOf(InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.
unsigned _nbOfEltConsumed
OutPort * getOutPort(const std::string &name) const
std::vector< int > _execIds
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 YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
Method used to notify the node that a child node has failed.
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
void init(bool start=true)
std::vector< Node * > _execFinalizeNodes
int getNumberOfOutputPorts() const
void prepareInputsFromOutOfScope(int branchNb)
virtual void cleanDynGraph()
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
void putValueOnBranch(Any *val, unsigned branchId, bool first)
AnyOutputPort _splittedPort
std::vector< Node * > _execInitNodes
std::list< InputPort * > getSetOfInputPort() const
TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned &id)
virtual void checkBasicConsistency() const
Base class for all calculation nodes.
void getReadyTasks(std::vector< Task * > &tasks)
Node * simpleClone(ComposedNode *father, bool editionOnly) const
FakeNodeForOptimizerLoop(OptimizerLoop *loop, bool normal, std::string message)
virtual std::set< OutPort * > edSetOutPort() const
Returns physical backlinks NOT user backlinks.
virtual int edGetNumberOfLinks() const
Returns number of physical backlinks NOT number of user backlinks.
Class that deal with list of semantics links for high level analysis.
Base class for all nodes.
virtual void exForwardFinished()
virtual void modified()
Sets Node in modified state and its father if it exists.
virtual std::string getOutPortName(const OutPort *) const =0
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
ComposedNode * getFather() const
void setState(YACS::StatesForNode theState)
Sets the given state for node.
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
virtual YACS::StatesForNode getState() const
const std::string & getName() const
virtual void exForwardFailed()
std::string _errorDetails
YACS::StatesForNode _state
virtual TypeCode * getTCForInProxy() const
virtual TypeCode * getTCForAlgoInitProxy() const
virtual void takeDecisionProxy()
virtual Any * getAlgoResultProxy()
virtual void finishProxy()
virtual void setError(const std::string &message)
virtual void setProc(Proc *proc)
virtual void initializeProxy(const Any *input)
virtual TypeCode * getTCForAlgoResultProxy() const
virtual const std::string & getError() const
virtual void startProxy()
virtual bool hasError() const
void setNbOfBranches(int nbOfBranches)
virtual TypeCode * getTCForOutProxy() const
class to build optimization loops
void buildDelegateOf(InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
virtual std::string getAlgLib() const
Return the name of the algorithm library.
void exUpdateState()
Update the node state.
std::map< InputPort *, std::vector< InputPort * > > _interceptors
outputports interceptors leaving current scope.
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
friend class FakeNodeForOptimizerLoop
AnyInputPort _algoInitPort
AnyOutputPort _algoResultPort
void initInterceptors(unsigned nbOfBr)
bool _convergenceReachedWithOtherCalc
virtual void accept(Visitor *visitor)
static const char NAME_OF_OUT_POOL_INPUT[]
bool isFullyBusy(unsigned &branchId) const
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.
AnyInputPort _retPortForOutPool
std::list< OutputPort * > getLocalOutputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
YACS::Event updateStateOnFinishedEventFrom(Node *node)
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...
std::list< OutputPort * > getSetOfOutputPort() const
static const int NOT_RUNNING_BRANCH_ID
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
FakeNodeForOptimizerLoop * _nodeForSpecialCases
static const char NAME_OF_ALGO_INIT_PORT[]
void pushValueOutOfScopeForCase(unsigned branchId)
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
int getNumberOfOutputPorts() const
int getNumberOfInputPorts() const
Node * simpleClone(ComposedNode *father, bool editionOnly=true) const
void getReadyTasks(std::vector< Task * > &tasks)
void selectRunnableTasks(std::vector< Task * > &tasks)
static const int NOT_INITIALIZED_BRANCH_ID
OptimizerLoop(const std::string &name, const std::string &algLibWthOutExt, const std::string &symbolNameToOptimizerAlgBaseInstanceFactory, bool algInitOnFile, bool initAlgo=true, Proc *procForTypes=NULL)
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
void init(bool start=true)
OutPort * getOutPort(const std::string &name) const
::YACS::BASES::DynLibLoader * _loader
static const char NAME_OF_ALGO_RESULT_PORT[]
TypeCode * checkTypeCode(TypeCode *tc, const char *portName)
virtual void loadAlgorithm()
Load the algorithm from the dynamic library.
std::vector< AnyInputPort * > _interceptorsForOutPool
void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
void launchMaxOfSamples(bool first)
std::vector< bool > _initNodeUpdated
virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
Method used to notify the node that a child node has failed.
void checkNoCyclePassingThrough(Node *node)
std::list< InputPort * > getSetOfInputPort() const
virtual void checkBasicConsistency() const
Check validity for the node.
virtual bool addInPort(InPort *inPort)=0
virtual int edGetNumberOfOutLinks() const
virtual bool edAddInputPort(InputPort *phyPort)
const std::set< InputPort * > & getSetOfPhyLinks() const
Returns physical links linked to this. Contrary to edSetInPort that returns semantic links.
void destroyCurrentCase()
void setCurrentId(int id)
void putOutSampleAt(int id, Any *outValue)
void markIdAsInUse(int id)
Any * getNextSampleWithHighestPriority(int &id, unsigned char &priority) const
Base class for all schema objects.
Base class for all type objects.
virtual void visitOptimizerLoop(OptimizerLoop *node)=0
const char * what(void) const noexcept
OptimizerAlgBase *(* OptimizerAlgBaseFactory)(Pool *pool)