Version: 9.16.0
PluginSimplex.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 "PluginSimplex.hxx"
21#include "TypeCode.hxx"
22#include "Pool.hxx"
23
24#include "saconst.h"
25
26#include "solution.hxx"
27
28#include <cmath>
29
30using namespace YACS::ENGINE;
31
32PluginSimplex::PluginSimplex(Pool *pool):OptimizerAlgSync(pool),_tc(0)
33{
34 // type
35 TypeCode *tctmp=new TypeCode(Double);
36 _tc=new TypeCodeSeq("", "", tctmp);
37 tctmp->decrRef();
38 // distribution
39 dst = (SalomeEventLoop *) NULL;
40 dec = (LinearDecoder *) NULL;
41 mtr = (Maestro *) NULL;
42 // swarm
43 solv = (Simplex *) NULL;
44
45}
46
48{
49 _tc->decrRef();
50 // distribution
51 delete dst;
52 delete dec;
53 delete mtr;
54 // swarm
55 delete solv;
56}
57
59{
60 return _tc;
61}
62
64{
65 return _tc;
66}
67
68void PluginSimplex::parseFileToInit(const std::string& fileName)
69{
70 std::vector<std::pair<double, double> > dom(NBGENE);
71 long i;
72
73 // domaine de recherche
74 for (i=0; i<NBGENE; i++) {
75 dom[i].first = BORNEMIN;
76 dom[i].second = BORNEMAX;
77 }
78 // distribution
80 dec = new LinearDecoder(dom);
81 mtr = new Maestro((Decoder &) *dec, (Critere *) NULL, (Distrib &) *dst);
82 // swarm
83 solv = new Simplex(NBNODE, NBGENE, *mtr);
84
86}
87
89{
90 solv->start();
91}
92
94{
95 int rien;
96 rien = solv->next();
97}
98
100{
101}
102
104{
105 Solution *res;
106
107 solv->finish();
108 res = solv->solution();
109 dec->echo(*res);
110}
111
113{
114 return new PluginSimplex(pool);
115}
116
OptimizerAlgBase * PluginSimplexFactory(Pool *pool)
void echo(Solution &)
Definition: decode.cxx:25
void start(void)
Definition: simplex.cxx:52
int next(void)
Definition: simplex.cxx:65
void finish(void)
Definition: simplex.cxx:90
void setStop(long)
Definition: simplex.cxx:47
Solution * solution(void)
Definition: simplex.cxx:96
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
Base class factorizing common methods for all algorithms interfaces.
TypeCode * getTCForOut() const
returns typecode of type expected as Output. OwnerShip of returned pointer is held by this.
void parseFileToInit(const std::string &fileName)
void initialize(const Any *input)
TypeCode * getTCForIn() const
returns typecode of type expected as Input. OwnerShip of returned pointer is held by this.
void takeDecision()
Update _pool attribute before performing anything.
Pool used to manage the samples of the optimizer loop plugin.
Definition: Pool.hxx:42
Class for sequence objects.
Definition: TypeCode.hxx:160
Base class for all type objects.
Definition: TypeCode.hxx:68
#define NBEVAL
Definition: saconst.h:34
#define BORNEMAX
Definition: saconst.h:56
#define NBGENE
Definition: saconst.h:50
#define BORNEMIN
Definition: saconst.h:55
#define NBNODE
Definition: saconst.h:29