source: colin/trunk/test/studies/TestOptSolver.h @ 5710

Revision 5710, 3.3 KB checked in by jdsiiro, 5 years ago (diff)

Misc colin changes:

  • renaming OptSolver_Base::derived_solver_type() -> define_solver_type() (closes ticket #4218)
  • reverting change of #include statements in OptSolver_Base.h from r5703
  • reverting addition of CommonIO dependence in OptSolver_Base.h from r5707
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*  _________________________________________________________________________
2 *
3 *  COLIN: A Common Optimization Library INterface
4 *  Copyright (c) 2003, Sandia National Laboratories.
5 *  This software is distributed under the GNU Lesser General Public License.
6 *  For more information, see the README.html file in the top COLIN directory.
7 *  _________________________________________________________________________
8 */
9
10/**
11 * \file TestOptSolver.h
12 *
13 * Defines TestOptSolver, a class that defines a simple solver
14 * for exercising COLIN.
15 */
16
17#include <acro_config.h>
18
19#include <utilib/PM_LCG.h>
20
21#include <colin/colin.h>
22#include <colin/ColinOptSolver.h>
23
24#include <boost/bind.hpp>
25#include <vector>
26
27using namespace colin;
28
29
30class TestOptSolver
31   : public ColinOptSolver<std::vector<double>, NLP0_problem>
32{
33public:
34   
35   TestOptSolver()
36   {
37      reset_signal.connect
38         ( boost::bind(&TestOptSolver::reset_TestOptSolver, this) );
39   }
40     
41    virtual ~TestOptSolver()
42      {}
43
44    void optimize();
45
46  private:
47    void reset_TestOptSolver()
48      {
49      pm_rng.set_seed(100);
50      set_rng(&pm_rng);
51      if (initial_point_flag)
52        { curr = initial_point; }
53      }
54
55  protected:
56   virtual std::string define_solver_type() const
57   { return "TestOptSolver"; }
58
59    void initialize_best_point()
60      {
61      initial_point.resize(problem->num_real_vars());
62      }
63
64    std::vector<double> curr;
65
66    utilib::PM_LCG pm_rng;
67
68  };
69
70
71class TestOptSolver_g
72  : public ColinOptSolver<std::vector<double>,NLP1_problem >
73  {
74  public:
75    TestOptSolver_g()
76   {
77      reset_signal.connect
78         ( boost::bind(&TestOptSolver_g::reset_TestOptSolver_g, this) );
79   }
80
81    virtual ~TestOptSolver_g()
82      {}
83
84    void optimize();
85
86    void reset_TestOptSolver_g()
87      {
88      pm_rng.set_seed(100);
89      set_rng(&pm_rng);
90      if (initial_point_flag)
91        { curr = initial_point; }
92      }
93
94  protected:
95   virtual std::string define_solver_type() const
96   { return "TestOptSolver_g"; }
97
98    void initialize_best_point()
99      { initial_point.resize(problem->num_real_vars()); }
100
101    std::vector<double> curr;
102    utilib::PM_LCG pm_rng;
103  };
104
105
106class AnotherOptSolver
107  : public ColinOptSolver<utilib::BasicArray<double>,NLP0_problem>
108  {
109  public:
110
111    AnotherOptSolver()
112   {
113      reset_signal.connect
114         ( boost::bind(&AnotherOptSolver::reset_AnotherOptSolver, this) );
115   }
116
117    virtual ~AnotherOptSolver()
118      {}
119
120    void optimize();
121
122    void reset_AnotherOptSolver()
123      {
124      pm_rng.set_seed(100);
125      set_rng(&pm_rng);
126      if (initial_point_flag)
127        { curr = initial_point; }
128      }
129
130
131  protected:
132   virtual std::string define_solver_type() const
133   { return "AnotherOptSolver"; }
134
135    void initialize_best_point()
136      { initial_point.resize(problem->num_real_vars()); }
137
138    utilib::BasicArray<double> curr;
139    utilib::PM_LCG pm_rng;
140  };
141
142
143#if 0
144class TestOptSolver_mf
145  : public ConcreteOptSolver<std::vector<double>,MONLP0_problem >
146  {
147  public:
148
149    TestOptSolver_mf()
150      {}
151
152    virtual ~TestOptSolver_mf()
153      {}
154
155    void minimize();
156
157    void reset()
158      {
159      ConcreteOptSolver<std::vector<double>,MONLP0_problem>::reset();
160      }
161
162  protected:
163
164    void initialize_best_point()
165      { initial_point.resize(problem->num_real_vars()); }
166  };
167#endif
168
169
Note: See TracBrowser for help on using the repository browser.