OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Match.h
Go to the documentation of this file.
1 #ifndef OPAL_Match_HH
2 #define OPAL_Match_HH 1
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Match.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class Match
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:33:44 $
17 // $Author: Andreas Adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "Match/MatchParser.h"
22 #include "Match/MatchState.h"
23 #include <string>
24 #include <list>
25 
26 class AbstractFun;
27 class AbstractVar;
28 class MatchParser;
29 
30 template <class T> class Vector;
31 
32 
33 // Class Match
34 // ------------------------------------------------------------------------
36 // This class encapsulates all data for matching which do not depend
37 // on the matching method.
38 // It acts as a communication area between the various matching commands.
39 
40 class Match {
41 
42 public:
43 
45  Match();
46 
47  ~Match();
48 
50  void addVariable(AbstractVar *);
51 
53  // Identified by name.
54  void deleteVariable(const std::string &name);
55 
57  // Identified by name.
58  AbstractVar *findVariable(const std::string &name);
59 
61  void getVariables(Vector<double> &x) const;
62 
64  void setVariables(const Vector<double> &x);
65 
67  int countVariables() const;
68 
70  void addFunction(AbstractFun *);
71 
73  // Set the matching variables to [b]x[/b], cache the function values,
74  // and return them in [b]f[/b]. The boolean return value indicates
75  // success (true) or failure (false).
76  bool evaluate(const Vector<double> &x, Vector<double> &f);
77 
79  void getFunctions(Vector<double> &f) const;
80 
82  int countFunctions() const;
83 
85  void print(const char *method, MatchState state);
86 
88  int getPrintLevel() const;
89 
91  void setPrintLevel(int);
92 
94  int getCallCount() const;
95 
98 
100  static Match *block;
101 
102 private:
103 
104  // Not implemented.
105  Match(const Match &);
106  void operator=(const Match &);
107 
108  // The list of access functions to variables.
109  typedef std::list<AbstractVar *> VarList;
111 
112  // The list of matching functions.
113  typedef std::list<AbstractFun *> FunList;
115 
116  // Counter for matched values.
118 
119  // Counter for functions calls.
121 
122  // The flag for printing.
124 };
125 
126 #endif // OPAL_Match_HH
void getFunctions(Vector< double > &f) const
Get cached values of matching functions.
Definition: Match.cpp:129
AbstractVar * findVariable(const std::string &name)
Find a matching variable.
Definition: Match.cpp:72
~Match()
Definition: Match.cpp:42
MatchState
The possible states of a matching process.
Definition: MatchState.h:29
void setPrintLevel(int)
Set the flag for printing.
Definition: Match.cpp:208
Match()
Constructor.
Definition: Match.cpp:38
Abstract base for matching constraints.
Definition: AbstractFun.h:32
void operator=(const Match &)
VarList theVariables
Definition: Match.h:110
static Match * block
The block of match data.
Definition: Match.h:100
int countFunctions() const
Return total number of functions.
Definition: Match.cpp:140
std::list< AbstractFun * > FunList
Definition: Match.h:113
void setVariables(const Vector< double > &x)
Set values of matching variables.
Definition: Match.cpp:93
void print(const char *method, MatchState state)
Print the results of minimisation.
Definition: Match.cpp:145
void addVariable(AbstractVar *)
Add a matching variable.
Definition: Match.cpp:55
MatchParser parser
The parser used during for matching.
Definition: Match.h:97
int countVariables() const
Get total number of variables.
Definition: Match.cpp:106
int callCount
Definition: Match.h:120
void deleteVariable(const std::string &name)
Delete a matching variable.
Definition: Match.cpp:60
The parser used in the OPAL match module.
Definition: MatchParser.h:32
bool evaluate(const Vector< double > &x, Vector< double > &f)
Evaluate the matching functions.
Definition: Match.cpp:117
void addFunction(AbstractFun *)
Add a set of matching function(s).
Definition: Match.cpp:111
int constraintCount
Definition: Match.h:117
std::list< AbstractVar * > VarList
Definition: Match.h:109
int printLevel
Definition: Match.h:123
Matching block.
Definition: Match.h:40
const std::string name
FunList theFunctions
Definition: Match.h:114
int getPrintLevel() const
Get the flag for printing.
Definition: Match.cpp:203
Abstract base for a matching variable.
Definition: AbstractVar.h:31
int getCallCount() const
Return count of function evaluations.
Definition: Match.cpp:213
Vector.
void getVariables(Vector< double > &x) const
Get values of matching variables.
Definition: Match.cpp:82