Version: 9.16.0
Simplex Class Reference

#include <simplex.hxx>

Collaboration diagram for Simplex:

Public Member Functions

 Simplex (long, long, Maestro &)
 
 ~Simplex (void)
 
void setStop (long)
 
void start (void)
 
int next (void)
 
void finish (void)
 
void solve (void)
 
Solutionsolution (void)
 

Protected Member Functions

Solutionadd (Solution *)
 
std::vector< double > * minimum (void)
 
std::vector< double > * barycentre (void)
 

Protected Attributes

long size
 
long nbin
 
long maxe
 
long nbeval
 
std::vector< Solution * > simplx
 
std::vector< Point * > work
 
Maestrocalc
 

Detailed Description

Definition at line 29 of file simplex.hxx.

Constructor & Destructor Documentation

◆ Simplex()

Simplex::Simplex ( long  sz,
long  nbgen,
Maestro maest 
)

Definition at line 26 of file simplex.cxx.

27{
28 size = sz;
29 nbin = nbgen;
30 calc = &maest;
31 maxe = 40000;
32 nbeval = 0;
33}
long maxe
Definition: simplex.hxx:31
Maestro * calc
Definition: simplex.hxx:34
long size
Definition: simplex.hxx:31
long nbeval
Definition: simplex.hxx:31
long nbin
Definition: simplex.hxx:31

References calc, maxe, nbeval, nbin, and size.

◆ ~Simplex()

Simplex::~Simplex ( void  )

Definition at line 35 of file simplex.cxx.

36{
37 int i;
38
39 if (work.size() == size) {
40 for (i=0; i<size; i++)
41 delete work[i];
42 for (i=0; i<nbin; i++)
43 delete simplx[i];
44 }
45}
std::vector< Point * > work
Definition: simplex.hxx:33
std::vector< Solution * > simplx
Definition: simplex.hxx:32

References yacsorb.CORBAEngineTest::i, nbin, simplx, size, and work.

Member Function Documentation

◆ add()

Solution * Simplex::add ( Solution sol)
protected

Definition at line 101 of file simplex.cxx.

102{
103 int i;
104 Solution *ret, *swp;
105
106 if (simplx.size() < nbin) {
107 ret = (Solution *) NULL;
108 i = simplx.size();
109 simplx.push_back(sol);
110 while (i && simplx[i]->obj[0] < simplx[i-1]->obj[0]) {
111 // TODO swap interne
112 swp = simplx[i];
113 simplx[i] = simplx[i-1];
114 simplx[i-1] = swp;
115 i--;
116 }
117 }
118 else if (sol->obj[0] > simplx[nbin-1]->obj[0])
119 ret = sol;
120 else {
121 i = nbin -1;
122 ret = simplx[i];
123 simplx[i] = sol;
124 while (i && simplx[i]->obj[0] < simplx[i-1]->obj[0]) {
125 swp = simplx[i];
126 simplx[i] = simplx[i-1];
127 simplx[i-1] = swp;
128 i--;
129 }
130 }
131 return ret;
132}
std::vector< double > * obj
Definition: solution.hxx:27

References yacsorb.CORBAEngineTest::i, nbin, Solution::obj, and simplx.

Referenced by next().

◆ barycentre()

std::vector< double > * Simplex::barycentre ( void  )
protected

Definition at line 139 of file simplex.cxx.

140{
141 int i,j;
142 std::vector<double> *ret;
143
144 ret = new std::vector<double>(nbin);
145 for (i=0; i<nbin; i++) {
146 (*ret)[i] = 0.0;
147 for (j=0; j<nbin; j++)
148 (*ret)[i] += (*simplx[j]->param)[i];
149 (*ret)[i] /= nbin;
150 }
151 return ret;
152}

References yacsorb.CORBAEngineTest::i, nbin, and simplx.

Referenced by next().

◆ finish()

void Simplex::finish ( void  )

Definition at line 90 of file simplex.cxx.

91{
92 std::cout << maxe - nbeval << std::endl;
93 return;
94}

References maxe, and nbeval.

Referenced by YACS::ENGINE::PluginSimplex::finish().

◆ minimum()

std::vector< double > * Simplex::minimum ( void  )
protected

Definition at line 134 of file simplex.cxx.

135{
136 return new std::vector<double>(*simplx[0]->param);
137}

References simplx.

Referenced by next().

◆ next()

int Simplex::next ( void  )

Definition at line 65 of file simplex.cxx.

66{
67 long id;
68 Solution *pt, *pnt;
69 std::vector<double> *next, *res;
70
71 res = calc->get(&id);
72 nbeval--;
73 pt = work[id]->inform(*res);
74 if (pt) {
75 pnt = add(pt);
76 if (pnt)
77 work[id]->mute(*pnt, *barycentre(), *minimum());
78 else
79 work[id]->reinit();
80 }
81 next = work[id]->next();
82 if (nbeval > size)
83 if (next)
84 calc->put(id, *next);
85 //else
86 // nbeval = size - 1;
87 return (nbeval > 0);
88}
std::vector< double > * get(long *)
Definition: maestro.cxx:38
void put(long, std::vector< double > &)
Definition: maestro.cxx:29
std::vector< double > * barycentre(void)
Definition: simplex.cxx:139
int next(void)
Definition: simplex.cxx:65
Solution * add(Solution *)
Definition: simplex.cxx:101
std::vector< double > * minimum(void)
Definition: simplex.cxx:134

References add(), barycentre(), calc, Maestro::get(), minimum(), nbeval, next(), Maestro::put(), size, and work.

Referenced by next(), start(), and YACS::ENGINE::PluginSimplex::takeDecision().

◆ setStop()

void Simplex::setStop ( long  max)

Definition at line 47 of file simplex.cxx.

48{
49 maxe = max;
50}

References maxe.

Referenced by YACS::ENGINE::PluginSimplex::parseFileToInit().

◆ solution()

Solution * Simplex::solution ( void  )

Definition at line 96 of file simplex.cxx.

97{
98 return simplx[0];
99}

References simplx.

Referenced by YACS::ENGINE::PluginSimplex::finish().

◆ solve()

void Simplex::solve ( void  )

◆ start()

void Simplex::start ( void  )

Definition at line 52 of file simplex.cxx.

53{
54 long i;
55
56 work.resize(size);
57 for (i=0; i<size; i++) {
58 work[i] = new Point(nbin);
59 calc->put(i, *(work[i]->next()));
60 }
61 nbeval = maxe;
62}
Definition: point.hxx:28

References calc, yacsorb.CORBAEngineTest::i, maxe, nbeval, nbin, next(), Maestro::put(), size, and work.

Referenced by YACS::ENGINE::PluginSimplex::start().

Member Data Documentation

◆ calc

Maestro* Simplex::calc
protected

Definition at line 34 of file simplex.hxx.

Referenced by next(), Simplex(), and start().

◆ maxe

long Simplex::maxe
protected

Definition at line 31 of file simplex.hxx.

Referenced by finish(), setStop(), Simplex(), and start().

◆ nbeval

long Simplex::nbeval
protected

Definition at line 31 of file simplex.hxx.

Referenced by finish(), next(), Simplex(), and start().

◆ nbin

long Simplex::nbin
protected

Definition at line 31 of file simplex.hxx.

Referenced by add(), barycentre(), Simplex(), start(), and ~Simplex().

◆ simplx

std::vector<Solution *> Simplex::simplx
protected

Definition at line 32 of file simplex.hxx.

Referenced by add(), barycentre(), minimum(), solution(), and ~Simplex().

◆ size

long Simplex::size
protected

Definition at line 31 of file simplex.hxx.

Referenced by next(), Simplex(), start(), and ~Simplex().

◆ work

std::vector<Point *> Simplex::work
protected

Definition at line 33 of file simplex.hxx.

Referenced by next(), start(), and ~Simplex().


The documentation for this class was generated from the following files: