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