Version: 9.16.0
Point Class Reference

#include <point.hxx>

Collaboration diagram for Point:

Public Member Functions

 Point (long)
 
 ~Point (void)
 
void reinit (void)
 
void mute (Solution &, std::vector< double > &, std::vector< double > &)
 
Solutioninform (std::vector< double > &)
 
std::vector< double > * next (void)
 

Private Member Functions

std::vector< double > * symetrique (std::vector< double > &, std::vector< double > &)
 
std::vector< double > * milieu (std::vector< double > &, std::vector< double > &)
 

Private Attributes

int size
 
int etat
 
double epsil
 
Cubernd
 
Solutionstart
 
std::vector< double > * courant
 
std::vector< double > * baryc
 
std::vector< double > * minim
 

Detailed Description

Definition at line 28 of file point.hxx.

Constructor & Destructor Documentation

◆ Point()

Point::Point ( long  sz)

Definition at line 36 of file point.cxx.

37{
38 size = sz;
39 etat = START;
40 epsil = SEUIL;
41 rnd = new Cube(size);
42 start = (Solution *) NULL;
43 courant = (std::vector<double> *) NULL;
44 baryc = (std::vector<double> *) NULL;
45 minim = (std::vector<double> *) NULL;
46}
Definition: aleas.hxx:37
double epsil
Definition: point.hxx:31
std::vector< double > * courant
Definition: point.hxx:34
int etat
Definition: point.hxx:30
std::vector< double > * minim
Definition: point.hxx:34
int size
Definition: point.hxx:30
Cube * rnd
Definition: point.hxx:32
Solution * start
Definition: point.hxx:33
std::vector< double > * baryc
Definition: point.hxx:34
#define START
Definition: point.cxx:24
#define SEUIL
Definition: point.cxx:34

References baryc, courant, epsil, etat, minim, rnd, SEUIL, size, START, and start.

◆ ~Point()

Point::~Point ( void  )

Definition at line 48 of file point.cxx.

49{
50 delete rnd;
51 if (courant)
52 delete courant;
53 if (start) {
54 delete start;
55 delete baryc;
56 delete minim;
57 }
58}

References baryc, courant, minim, rnd, and start.

Member Function Documentation

◆ inform()

Solution * Point::inform ( std::vector< double > &  obj)

Definition at line 60 of file point.cxx.

61{
62 Solution *res, *tmp;
63
64 res = (Solution *) NULL;
65 switch (etat) {
66 case START :
67#ifdef SHOW
68 std::cout << "@" ;
69#endif
70 res = new Solution(*courant, obj);
71 break;
72 case FIRST :
73 if (obj[0] > (*start->obj)[0]) {
74#ifdef SHOW
75 std::cout << "-" ;
76#endif
77 etat = BAD ;
78 delete courant;
79 delete &obj;
80 }
81 else {
82#ifdef SHOW
83 std::cout << "+" ;
84#endif
85 etat = GOOD ;
86 tmp = start;
87 start = new Solution(*courant, obj);
88 delete tmp;
89 }
90 break;
91 case GOOD :
92 if (obj[0] > (*start->obj)[0]) {
93#ifdef SHOW
94 std::cout << "P" ;
95#endif
96 etat = SOGOOD;
97 delete courant;
98 delete &obj;
99 res = start;
100 delete baryc;
101 delete minim;
102 start = (Solution *) NULL;
103 }
104 else {
105#ifdef SHOW
106 std::cout << "p" ;
107#endif
108 etat = TOOGOOD;
109 res = new Solution(*courant, obj);
110 }
111 break;
112 case BAD :
113 if (obj[0] > (*start->obj)[0]) {
114#ifdef SHOW
115 std::cout << "M" ;
116#endif
117 etat = TOOBAD;
118 delete courant;
119 delete &obj;
120 }
121 else {
122#ifdef SHOW
123 std::cout << "m" ;
124#endif
125 etat = SOBAD;
126 res = new Solution(*courant, obj);
127 }
128 break;
129 case TOOBAD:
130#ifdef SHOW
131 std::cout << "X" ;
132#endif
133 etat = BADEST;
134 res = new Solution(*courant, obj);
135 break;
136 default :
137 std::cout << "pbl inform" << std::endl ;
138 break;
139 }
140 return res;
141}
std::vector< double > * obj
Definition: solution.hxx:27
#define TOOGOOD
Definition: point.cxx:28
#define FIRST
Definition: point.cxx:25
#define TOOBAD
Definition: point.cxx:30
#define GOOD
Definition: point.cxx:26
#define SOGOOD
Definition: point.cxx:27
#define BADEST
Definition: point.cxx:32
#define SOBAD
Definition: point.cxx:31
#define BAD
Definition: point.cxx:29

References BAD, BADEST, baryc, courant, etat, FIRST, GOOD, minim, Solution::obj, SOBAD, SOGOOD, START, start, TOOBAD, and TOOGOOD.

◆ milieu()

std::vector< double > * Point::milieu ( std::vector< double > &  un,
std::vector< double > &  deux 
)
private

Definition at line 226 of file point.cxx.

227{
228 long i;
229 std::vector<double> *res;
230
231 res = new std::vector<double>(size);
232 for (i=0; i<size; i++)
233 (*res)[i] = (un[i] + deux[i])/2.0;
234 return res;
235}

References yacsorb.CORBAEngineTest::i, and size.

Referenced by next().

◆ mute()

void Point::mute ( Solution pt,
std::vector< double > &  bary,
std::vector< double > &  minm 
)

Definition at line 143 of file point.cxx.

144{
145 std::vector<double> *tmp;
146
147 if (start) {
148 delete baryc;
149 delete minim;
150 delete start;
151 }
152 start = &pt;
153 baryc = &bary;
154 minim = &minm;
155 etat = FIRST;
156}

References baryc, etat, FIRST, minim, and start.

◆ next()

std::vector< double > * Point::next ( void  )

Definition at line 163 of file point.cxx.

164{
165 double d, dd;
166 int i;
167
168 switch (etat) {
169 case START :
170 courant = rnd->gen();
171 break;
172 case FIRST :
174 break;
175 case GOOD :
177 break;
178 case BAD :
180 break;
181 case TOOBAD :
183 break;
184 default:
185 // raise
186 std::cout << "pbl next" << std::endl ;
187 }
188 if (baryc) {
189 d=0.0;
190 for (i=0; i<size; i++) {
191 dd = (*courant)[0] - (*baryc)[0];
192 d += dd*dd;
193 }
194 }
195 else
196 d=1.0;
197 if (d < epsil) {
198 //delete courant;
199 return (std::vector<double> *) NULL;
200 }
201 else
202 return courant;
203}
virtual std::vector< double > * gen(void)
Definition: aleas.cxx:111
std::vector< double > * symetrique(std::vector< double > &, std::vector< double > &)
Definition: point.cxx:205
std::vector< double > * milieu(std::vector< double > &, std::vector< double > &)
Definition: point.cxx:226
std::vector< double > * param
Definition: solution.hxx:27

References BAD, baryc, courant, epsil, etat, FIRST, Aleatoire::gen(), GOOD, yacsorb.CORBAEngineTest::i, milieu(), minim, Solution::param, rnd, size, START, start, symetrique(), and TOOBAD.

◆ reinit()

void Point::reinit ( void  )

Definition at line 158 of file point.cxx.

159{
160 etat = START;
161}

References etat, and START.

◆ symetrique()

std::vector< double > * Point::symetrique ( std::vector< double > &  pt,
std::vector< double > &  centr 
)
private

Definition at line 205 of file point.cxx.

206{
207 long i;
208 double coef, tmp;
209 std::vector<double> *res;
210
211 // bounded coef
212 coef = 1.0;
213 for (i=0; i<size; i++) {
214 tmp = (centr[i]-pt[i] > 0.0) ?
215 (1.0 - centr[i]) / (centr[i] - pt[i]) :
216 centr[i] / (pt[i] - centr[i]) ;
217 coef = (coef < tmp) ? coef : tmp ;
218 }
219 //
220 res = new std::vector<double>(size);
221 for (i=0; i<size; i++)
222 (*res)[i] = centr[i] + coef * (centr[i] - pt[i]);
223 return res;
224}

References yacsorb.CORBAEngineTest::i, and size.

Referenced by next().

Member Data Documentation

◆ baryc

std::vector<double> * Point::baryc
private

Definition at line 34 of file point.hxx.

Referenced by inform(), mute(), next(), Point(), and ~Point().

◆ courant

std::vector<double>* Point::courant
private

Definition at line 34 of file point.hxx.

Referenced by inform(), next(), Point(), and ~Point().

◆ epsil

double Point::epsil
private

Definition at line 31 of file point.hxx.

Referenced by next(), and Point().

◆ etat

int Point::etat
private

Definition at line 30 of file point.hxx.

Referenced by inform(), mute(), next(), Point(), and reinit().

◆ minim

std::vector<double> * Point::minim
private

Definition at line 34 of file point.hxx.

Referenced by inform(), mute(), next(), Point(), and ~Point().

◆ rnd

Cube* Point::rnd
private

Definition at line 32 of file point.hxx.

Referenced by next(), Point(), and ~Point().

◆ size

int Point::size
private

Definition at line 30 of file point.hxx.

Referenced by milieu(), next(), Point(), and symetrique().

◆ start

Solution* Point::start
private

Definition at line 33 of file point.hxx.

Referenced by inform(), mute(), next(), Point(), and ~Point().


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