Version: 8.3.0
Emulator Class Reference

#include <saemul.hxx>

Inheritance diagram for Emulator:
Collaboration diagram for Emulator:

Public Member Functions

 Emulator (void)
 
 ~Emulator (void)
 
void destroyAll (void)
 
void push (long id, std::vector< double > &cal)
 
long getCurrentId (void)
 
std::vector< double > * getCurrentOut (void)
 
void run (void)
 

Protected Member Functions

std::vector< double > * eval (std::vector< double > &x)
 

Protected Attributes

SalomeTestsolver
 
std::queue< std::pair< long,
std::vector< double > * > > 
q
 
std::vector< double > * out
 

Detailed Description

Definition at line 31 of file saemul.hxx.

Constructor & Destructor Documentation

Emulator::Emulator ( void  )

Definition at line 26 of file saemul.cxx.

References solver.

27 {
28  solver = new SalomeTest((Superviseur &) *this);
29 }
Emulator::~Emulator ( void  )

Definition at line 31 of file saemul.cxx.

References destroyAll(), and solver.

32 {
33  delete solver;
34  destroyAll();
35 }

Member Function Documentation

void Emulator::destroyAll ( void  )
virtual

Implements Superviseur.

Definition at line 37 of file saemul.cxx.

References q.

Referenced by ~Emulator().

38 {
39  std::pair<long,std::vector<double> *> pa;
40 
41  while (! q.empty()) {
42  pa = q.front();
43  q.pop();
44  delete pa.second;
45  }
46 }
std::vector< double > * Emulator::eval ( std::vector< double > &  x)
protected

Definition at line 74 of file saemul.cxx.

References CORBAEngineTest::i, and NBGENE.

Referenced by getCurrentId().

75 {
76  std::vector<double> *res;
77  res = new std::vector<double>(1);
78 #ifdef TRIPOD
79  //Tripod
80  double x1, x2;
81 
82  x1 = x[0]; x2 = x[1];
83 
84  if (x2 < 0)
85  (*res)[0] = fabs(x1) + fabs(x2+50);
86  else {
87  (*res)[0] = fabs(x2-50);
88  if (x1 < 0)
89  (*res)[0] += 1 + fabs(x1+50);
90  else
91  (*res)[0] += 2 + fabs(x1-50);
92  }
93 #endif
94 #ifdef ROSENBROCK
95  // rosenbrock
96  double x1, x2;
97 
98  x1 = x[0] ; x2 = x1*x1 - x[1]; x1 -= 1;
99  (*res)[0] = x1*x1 + 100*x2*x2 ;
100 #endif
101 #ifdef GRIEWANK
102  double x1, x2, y;
103  int i;
104 
105  x1 = 0.0; x2 = 1.0;
106  for (i=0; i<NBGENE; i++) {
107  y = 3*x[i] - 100;
108  x1 += y*y;
109  x2 *= cos(y/sqrt(i+1));
110  }
111  (*res)[0] = x1 / 4000 - x2 + 1;
112 #endif
113  return res;
114 }
long Emulator::getCurrentId ( void  )
virtual

Implements Superviseur.

Definition at line 57 of file saemul.cxx.

References eval(), out, and q.

58 {
59  std::vector<double> *cal;
60  std::pair<long,std::vector<double> *> pa;
61 
62  pa = q.front(); q.pop();
63  cal = pa.second;
64  out = eval(*cal);
65  delete cal;
66  return pa.first;
67 }
std::vector< double > * Emulator::getCurrentOut ( void  )
virtual

Implements Superviseur.

Definition at line 69 of file saemul.cxx.

References out.

70 {
71  return out;
72 }
void Emulator::push ( long  id,
std::vector< double > &  cal 
)
virtual

Implements Superviseur.

Definition at line 48 of file saemul.cxx.

References q.

49 {
50  std::pair<long, std::vector<double> *> *tmp;
51 
52  tmp = new std::pair<long, std::vector<double> *>(id, &cal);
53  q.push(*tmp);
54  delete tmp;
55 }
void Emulator::run ( void  )

Definition at line 116 of file saemul.cxx.

References SalomeTest::finish(), SalomeTest::next(), q, SalomeTest::readFromFile(), solver, and SalomeTest::start().

Referenced by main().

117 {
118  solver->readFromFile("caca");
119  solver->start();
120  while (! q.empty())
121  solver->next();
122  solver->finish();
123 }

Member Data Documentation

std::vector<double>* Emulator::out
protected

Definition at line 35 of file saemul.hxx.

Referenced by getCurrentId(), and getCurrentOut().

std::queue<std::pair<long, std::vector<double> *> > Emulator::q
protected

Definition at line 34 of file saemul.hxx.

Referenced by destroyAll(), getCurrentId(), push(), and run().

SalomeTest* Emulator::solver
protected

Definition at line 33 of file saemul.hxx.

Referenced by Emulator(), run(), and ~Emulator().


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