Version: 9.16.0
OptimizerAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "OptimizerAlg.hxx"
21#include "Runtime.hxx"
22
23using namespace YACS::BASES;
24using namespace YACS::ENGINE;
25
26OptimizerAlgBase::OptimizerAlgBase(Pool *pool):_pool(pool), _proc(NULL)
27{
28}
29
31{
32}
33
35{
36}
37
39{
40}
41
43{
45}
46
48{
50}
51
53{
54 return NULL;
55}
56
58{
59 return getTCForIn();
60}
61
63{
64 return getTCForOut();
65}
66
68{
69 return getTCForAlgoInit();
70}
71
73{
74 return getTCForAlgoResult();
75}
76
78{
79 initialize(input);
80}
81
83{
84 start();
85}
86
88{
90}
91
93{
94 finish();
95 _errorMessage = "";
96}
97
99{
100 return getAlgoResult();
101}
102
104{
105 _pool=pool;
106}
107
109{
110 _proc = proc;
111}
112
114{
115 return _proc;
116}
117
119{
120 return (_errorMessage.length() > 0);
121}
122
123const std::string & OptimizerAlgBase::getError() const
124{
125 return _errorMessage;
126}
127
128void OptimizerAlgBase::setError(const std::string & message)
129{
130 _errorMessage = (message.length() > 0) ? message : "Unknown error";
131}
132
134{
135 _nbOfBranches=nbOfBranches;
136}
137
139{
140 return _nbOfBranches;
141}
142
144{
145}
146
148{
149}
150
152{
153 terminateSlaveThread();
155}
156
158{
159 signalSlaveAndWait();
160}
161
163{
164 AlternateThread::start();
165}
166
168{
170 _pool->destroyAll();
171}
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
virtual void startToTakeDecision()=0
virtual void takeDecision()
Update _pool attribute before performing anything.
virtual void start()
Called when optimization has succeed.
Base class factorizing common methods for all algorithms interfaces.
virtual TypeCode * getTCForAlgoInit() const
returns typecode of type expected for algo initialization. OwnerShip of returned pointer is held by t...
virtual TypeCode * getTCForInProxy() const
virtual TypeCode * getTCForAlgoInitProxy() const
virtual void takeDecision()=0
Update _pool attribute before performing anything.
virtual TypeCode * getTCForAlgoResult() const
returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
virtual TypeCode * getTCForOut() const =0
returns typecode of type expected as Output. OwnerShip of returned pointer is held by this.
virtual Any * getAlgoResultProxy()
virtual Any * getAlgoResult()
Called when optimization has succeed.
virtual TypeCode * getTCForIn() const =0
returns typecode of type expected as Input. OwnerShip of returned pointer is held by this.
virtual void setPool(Pool *pool)
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 bool hasError() const
void setNbOfBranches(int nbOfBranches)
virtual void initialize(const Any *input)
virtual TypeCode * getTCForOutProxy() const
Pool used to manage the samples of the optimizer loop plugin.
Definition: Pool.hxx:42
void destroyAll()
Definition: Pool.cxx:122
Base class for all schema objects.
Definition: Proc.hxx:44
static YACS::ENGINE::TypeCode * _tc_string
Definition: Runtime.hxx:139
Base class for all type objects.
Definition: TypeCode.hxx:68