Debian Codegraph @

Bonmin/src/Algorithms/Ampl/BonAmplSetup.cpp

raw
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, International Business Machines Corporation
7 //
8 // Date : 04/15/2007
9
10 #include "BonAmplSetup.hpp"
11 #include "BonSolReader.hpp"
12 namespace Bonmin
13 {
14 void BonminAmplSetup::initialize(char **& argv)
15 {
16 readOptionsFile();
17 /* Read the model.*/
18 Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(), options(),
19 argv, NULL, "bonmin", NULL);
20 mayPrintDoc();
21 BonminSetup::initialize(GetRawPtr(model), true);
22 #if 1
23 int ival;
24 options()->GetEnumValue("read_solution_file", ival, "bonmin.");
25 if(ival){
26 printf("Reading solution file");
27 SolReader read(argv[1], ".dbg_sol");
28 read.set_n_cols(nonlinearSolver()->getNumCols());
29 read.readFile();
30 nonlinearSolver()->activateRowCutDebugger(read.x());
31 }
32 #endif
33 }
34
35 void
36 BonminAmplSetup::initialize(AmplInterface &toFill, char **& argv)
37 {
38 Ipopt::SmartPtr<TNLPSolver> solver = toFill.solver();
39 setOptionsAndJournalist(solver->roptions(),
40 solver->options(),
41 solver->journalist());
42 /* Get the basic options. */
43 readOptionsFile();
44 /* Read the model.*/
45 Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
46 options(), argv, NULL, "bonmin", NULL);
47 mayPrintDoc();
48 toFill.initialize(roptions_, options_, journalist_, prefix(), GetRawPtr(model));
49 BonminSetup::initialize(toFill, true);
50 }
51
52 /** initialize bonmin with ampl model using the command line arguments reading options and nl file from strings.*/
53 void
54 BonminAmplSetup::initialize(char **& argv, std::string& opt_file_content, std::string& nl_file_content, bool createContinuousSolver /*= false*/)
55 {
56 /* Get the basic options. */
57 readOptionsString(opt_file_content);
58 /* read nl file by creating AmplTMINLP.*/
59 Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
60 options(), argv, NULL, "bonmin", &nl_file_content);
61 mayPrintDoc();
62 BonminSetup::initialize(GetRawPtr(model), createContinuousSolver);
63 }
64
65
66 /** initialize bonmin with ampl model using the command line arguments and an existing OsiTMINLPInterface reading options and nl file from strings.*/
67 void
68 BonminAmplSetup::initialize(AmplInterface &toFill, char **& argv, std::string& opt_file_content,
69 std::string& nl_file_content, bool createContinuousSolver /*= false*/
70 )
71 {
72 /* Get the basic options. */
73 readOptionsString(opt_file_content);
74 /* read nl file by creating AmplTMINLP.*/
75 Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
76 options(), argv, NULL, "bonmin", &nl_file_content);
77 mayPrintDoc();
78 toFill.initialize(roptions_, options_, journalist_, prefix(), GetRawPtr(model));
79 BonminSetup::initialize(toFill, createContinuousSolver);
80 }
81
82 /** Usefull for Bcp */
83 void BonminAmplSetup::fillOsiInterface(AmplInterface &toFill, char ** &argv, std::string & options,
84 std::string & nl, bool createContinuousSolver /*= false*/)
85 {
86
87 /* Get the basic options. */
88 readOptionsString(options);
89 /* Read the model.*/
90 Ipopt::SmartPtr<AmplTMINLP> model =
91 new AmplTMINLP(ConstPtr(journalist_),
92 roptions_,
93 options_,
94 argv, NULL, "bonmin", &nl);
95 toFill.initialize(roptions(), options_, journalist(), prefix(), GetRawPtr(model));
96 }
97
98 }
99