29 using namespace YACS::ENGINE;
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):
101 DynParaLoop(name,
Runtime::_tc_string),_algInitOnFile(algInitOnFile),_alglib(algLibWthOutExt),
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");
253 catch (
const exception & e)
256 string(
"An error happened in the control algorithm of OptimizerLoop \"") +
_name +
268 if (name == NAME_OF_ALGO_INIT_PORT)
270 else if (name == NAME_OF_OUT_POOL_INPUT)
307 vector<Node *>::iterator iter;
309 (*iter)->getReadyTasks(tasks);
311 (*iter)->getReadyTasks(tasks);
313 (*iter)->getReadyTasks(tasks);
350 _errorDetails = string(
"An error happened in the control algorithm of optimizer loop: ") +
371 unsigned char priority;
380 std::cerr <<
"OptimizerLoop::updateStateOnFinishedEventFrom: Alg has not inserted more cases whereas last element has been calculated !" << std::endl;
420 std::list<Node *>::iterator iter=aChldn.begin();
421 for(;iter!=aChldn.end();iter++)
440 DEBTRACE(
"Launching finalize node for branch " <<
i)
461 DEBTRACE(
"OptimizerLoop::updateStateOnFailedEventFrom " << node->
getName());
466 DEBTRACE(
"OptimizerLoop::updateStateOnFailedEventFrom: returned from error notification.");
479 std::string linkName(
"(");
481 throw Exception(std::string(
"Illegal OptimizerLoop link: \
482 The 'evalResults' port must be linked within the scope of the loop.")
492 std::string linkName(
"(");
493 linkName += port.first->getName()+
" to "+finalTarget->
getName()+
")";
494 throw Exception(std::string(
"Illegal OptimizerLoop link: \
495 Only the algorithm result port can be linked to a port outside the scope of the loop.")
499 string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
501 throw Exception(
"OptimizerLoop::buildDelegateOf : not implemented for DS because not specified ");
506 std::vector<OutPort *>& fwCross,
528 std::string linkName(
"(");
529 linkName += start->getName()+
" to "+end->getName()+
")";
532 if(end == &_nbOfBranches || end == &_algoInitPort)
533 if(start != &_algoResultPort)
534 throw Exception(std::string(
"Illegal OptimizerLoop link.") + linkName);
538 if(start == &_algoResultPort)
539 throw Exception(std::string(
"Illegal OptimizerLoop link: \
540 The 'algoResult' port can't be linked within the scope of the loop.") + linkName);
542 if(end == &_retPortForOutPool && isInMyDescendance(start->getNode())!=_node)
543 throw Exception(std::string(
"Illegal OptimizerLoop link: \
544 The 'evalResults' port can only be linked to the working node.") + linkName);
550 map<InputPort *,vector<InputPort *> >::iterator iter=
_interceptors.begin();
552 for(vector<InputPort *>::iterator iter2=(*iter).second.begin();iter2!=(*iter).second.end();iter2++)
563 unsigned char priority;
625 for(set<OutPort *>::iterator iter=portsToIntercept.begin();iter!=portsToIntercept.end();iter++)
629 for(set<InputPort *>::const_iterator iter2=links.begin();iter2!=links.end();iter2++)
641 for(
unsigned i=0;
i<nbOfBr;
i++)
651 for(
unsigned i=0;
i<nbOfBr;
i++)
663 for(
unsigned i=0;
i<nbOfBr;
i++)
665 for(set<OutPort *>::iterator iter2=links.begin();iter2!=links.end();iter2++)
666 for(
unsigned j=0;j<nbOfBr;j++)
675 else if(whatType==
_initNode && whatType!=0)
689 map<InputPort *, std::vector<InputPort *> >::iterator iter;
691 (*iter).first->put((*iter).second[branchId]->get());
704 bool checkLinks,
Proc * procForTypes)
712 throw Exception(
"The OptimizerLoop node must be disconnected before setting the algorithm");
746 ostringstream errorMsg;
747 errorMsg <<
"The algorithm specified for OptimizerLoop node \"" <<
getName() <<
748 "\" provided an invalid type for port \"" << portName <<
"\"";
784 if (algFactory != NULL)
803 DEBTRACE(
"OptimizerLoop::checkBasicConsistency");
805 throw Exception(
"No library specified for the OptimizerLoop control algorithm");
807 throw Exception(
"No symbol specified for the OptimizerLoop control algorithm");
835 return (name == NAME_OF_ALGO_RESULT_PORT) ? (
OutPort *)&_algoResultPort :
842 return (name == NAME_OF_ALGO_RESULT_PORT) ? (
OutputPort *)&_algoResultPort :