Salome HOME
updated copyright message
[modules/yacs.git] / src / engine / Plugin / saclass.cxx
1 // Copyright (C) 2006-2023  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 "saclass.hxx"
21
22 #include <utility>
23
24 #include "topologie.hxx"
25
26 #include "saconst.h"
27
28
29
30 SalomeTest::SalomeTest(Superviseur &t)
31 {
32     super = &t;
33     rnd1 = (SpherePositif *) NULL;
34     st1 = (Traditionnel *) NULL;
35     rnd2 = (Sphere *) NULL;
36     st2 = (Pivot *) NULL;
37     // distribution
38     dst = (SalomeEventLoop *) NULL;
39     dec = (LinearDecoder *) NULL;
40     mtr = (Maestro *) NULL;
41     // swarm
42     swrm = (MonoSwarm *) NULL;
43
44 }
45
46 SalomeTest::~SalomeTest(void)
47 {
48     delete rnd1;
49     delete rnd2;
50     delete st1;
51     delete st2;
52     // distribution
53     delete dst;
54     delete dec;
55     delete mtr;
56     // swarm
57     delete swrm;
58 }
59
60 void SalomeTest::readFromFile(std::string rien)
61 {
62     std::vector<std::pair<double, double> > dom(NBGENE);
63     long    i;
64
65     // domaine de recherche
66     for (i=0; i<NBGENE; i++) {
67         dom[i].first = BORNEMIN;
68         dom[i].second = BORNEMAX;
69     }
70     // topologie
71     Plan  top(COTE,COTE);
72     // operateur stochastique
73     rnd1 = new SpherePositif(NBGENE);
74     st1 = new Traditionnel(NBGENE, *rnd1);
75     rnd2 = new Sphere(NBGENE);
76     st2 = new Pivot(NBGENE, *rnd2);
77     // distribution
78     dst = new SalomeEventLoop(*super);
79     dec = new LinearDecoder(dom);
80     mtr = new Maestro((Decoder &) *dec, (Critere *) NULL, (Distrib &) *dst);
81     // swarm
82     swrm = new MonoSwarm(PLAN, NBGENE, (Topologie &) top, (Movement &) *st1, (Movement &) *st1, *mtr);
83     
84     swrm->setStop(NBEVAL);
85 }
86
87 void SalomeTest::start(void)
88 {
89     swrm->start();
90 }
91
92 void SalomeTest::next(void)
93 {
94     int     rien;
95     rien = swrm->next();
96 }
97
98 void SalomeTest::finish(void)
99 {
100     Solution        *res;
101
102     swrm->finish();
103     res = swrm->solution();
104     dec->echo(*res);
105 }
106