Version: 8.3.0
PluginSimplex.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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 
30 using namespace YACS::ENGINE;
31 
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 
68 void 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
79  dst = new SalomeEventLoop(_pool);
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