source: colin/branches/colin-appresponse-dev/src/UnconMultiobjApplication.cpp @ 5536

Revision 5536, 2.3 KB checked in by jdsiiro, 6 years ago (diff)
  • decentralizing registration of ProblemMngr?() transformations
  • completed ApplicationMngr?() registrations for reformulation applications
  • bugfixes in several reformulation templates that had not been instantiated.
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#include <colin/UnconMultiobjApplication.h>
11#include <colin/ApplicationMngr.h>
12
13using std::pair;
14using utilib::Any;
15
16namespace colin {
17
18namespace StaticInitializers {
19
20namespace {
21
22
23template <class FROM, class TO>
24int lexical_cast_UnconMultiobjProblem(const Any& from, Any& to)
25{
26   pair<ApplicationHandle,UnconMultiobjApplication<TO>*> tmp
27      = ApplicationHandle::create<UnconMultiobjApplication<TO> >();
28   tmp.second->set_base_application
29      ( from.template expose<OptProblem<FROM> >()->get_handle() );
30
31   to.template set< OptProblem<TO> >().set_application(tmp.second);
32   return 0;
33}
34
35bool RegisterUnconMultiobj()
36{
37   // ------------------------------------------------------------------
38   // Register creatable instances with the ApplicationMngr
39
40   ApplicationMngr().declare_application_type
41      <UnconMultiobjApplication<MO_UNLP0_problem> >
42      ("UnconstrainedMultiobjReformulation");
43
44   ApplicationMngr().declare_application_type
45      <UnconMultiobjApplication<MO_UMINLP0_problem> >
46      ("UnconstrainedMultiobjReformulation");
47
48
49   // ------------------------------------------------------------------
50   // Register default problem transformations with the ProblemMngr
51
52   ProblemMngr().register_lexical_cast
53      (typeid(OptProblem<MO_NLP0_problem>),
54       typeid(OptProblem<MO_UNLP0_problem>),
55       &lexical_cast_UnconMultiobjProblem<MO_NLP0_problem, MO_UNLP0_problem>,
56       false);
57   ProblemMngr().register_lexical_cast
58      (typeid(OptProblem<MO_MINLP0_problem>),
59       typeid(OptProblem<MO_UMINLP0_problem>),
60       &lexical_cast_UnconMultiobjProblem< MO_MINLP0_problem,
61                                           MO_UMINLP0_problem >,
62       false);
63
64   return true;
65}
66
67} // namespace colin::StaticInitializers::(local)
68
69extern const volatile bool uncon_multiobj = RegisterUnconMultiobj();
70
71} // namespace colin::StaticInitializers
72
73} // namespace colin
Note: See TracBrowser for help on using the repository browser.