1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
42 start = (Solution *) NULL;
43 courant = (std::vector<double> *) NULL;
44 baryc = (std::vector<double> *) NULL;
45 minim = (std::vector<double> *) NULL;
60 Solution *Point::inform(std::vector<double> &obj)
64 res = (Solution *) NULL;
70 res = new Solution(*courant, obj);
73 if (obj[0] > (*start->obj)[0]) {
87 start = new Solution(*courant, obj);
92 if (obj[0] > (*start->obj)[0]) {
102 start = (Solution *) NULL;
109 res = new Solution(*courant, obj);
113 if (obj[0] > (*start->obj)[0]) {
126 res = new Solution(*courant, obj);
134 res = new Solution(*courant, obj);
137 std::cout << "pbl inform" << std::endl ;
143 void Point::mute(Solution &pt, std::vector<double> &bary, std::vector<double> &minm)
145 std::vector<double> *tmp;
158 void Point::reinit(void)
163 std::vector<double> *Point::next(void)
170 courant = rnd->gen();
173 courant = symetrique(*start->param, *baryc);
176 courant = symetrique(*baryc, *start->param);
179 courant = milieu(*baryc, *start->param);
182 courant = milieu(*minim, *start->param);
186 std::cout << "pbl next" << std::endl ;
190 for (i=0; i<size; i++) {
191 dd = (*courant)[0] - (*baryc)[0];
199 return (std::vector<double> *) NULL;
205 std::vector<double> *Point::symetrique(std::vector<double> &pt, std::vector<double> ¢r)
209 std::vector<double> *res;
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 ;
220 res = new std::vector<double>(size);
221 for (i=0; i<size; i++)
222 (*res)[i] = centr[i] + coef * (centr[i] - pt[i]);
226 std::vector<double> *Point::milieu(std::vector<double> &un, std::vector<double> &deux)
229 std::vector<double> *res;
231 res = new std::vector<double>(size);
232 for (i=0; i<size; i++)
233 (*res)[i] = (un[i] + deux[i])/2.0;