/home/coin/SVN-release/OS-2.4.0/Bonmin/src/Algorithms/Ampl/BonAmplSetup.cpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, International Business Machines Corporation
00007 //
00008 // Date : 04/15/2007
00009 
00010 #include "BonAmplSetup.hpp"
00011 #include "BonSolReader.hpp"
00012 namespace Bonmin
00013 {
00014   void BonminAmplSetup::initialize(char **& argv)
00015   {
00016     readOptionsFile();
00017     /* Read the model.*/
00018     Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(), options(),
00019                                                 argv, NULL, "bonmin", NULL);
00020     mayPrintDoc();
00021     BonminSetup::initialize(GetRawPtr(model), true);
00022 #if 1
00023     int ival;
00024     options()->GetEnumValue("read_solution_file", ival, "bonmin.");
00025     if(ival){
00026       printf("Reading solution file");
00027       SolReader read(argv[1], ".dbg_sol");
00028       read.set_n_cols(nonlinearSolver()->getNumCols());
00029       read.readFile();
00030       nonlinearSolver()->activateRowCutDebugger(read.x());
00031     }
00032 #endif
00033   }
00034 
00035   void
00036   BonminAmplSetup::initialize(AmplInterface &toFill, char **& argv)
00037   {
00038     Ipopt::SmartPtr<TNLPSolver> solver = toFill.solver();
00039     setOptionsAndJournalist(solver->roptions(),
00040         solver->options(),
00041         solver->journalist());
00042     /* Get the basic options. */
00043     readOptionsFile();
00044     /* Read the model.*/
00045     Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
00046                                                 options(), argv, NULL, "bonmin", NULL);
00047     mayPrintDoc();
00048     toFill.initialize(roptions_, options_, journalist_, prefix(), GetRawPtr(model));
00049     BonminSetup::initialize(toFill, true);
00050   }
00051 
00053   void
00054   BonminAmplSetup::initialize(char **& argv, std::string& opt_file_content, std::string& nl_file_content, bool createContinuousSolver /*= false*/)
00055   {
00056     /* Get the basic options. */
00057     readOptionsString(opt_file_content);
00058     /* read nl file by creating AmplTMINLP.*/
00059     Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
00060                                                 options(), argv, NULL, "bonmin", &nl_file_content);
00061     mayPrintDoc();
00062     BonminSetup::initialize(GetRawPtr(model), createContinuousSolver);
00063   }
00064 
00065 
00067   void
00068   BonminAmplSetup::initialize(AmplInterface &toFill, char **& argv, std::string& opt_file_content,
00069       std::string& nl_file_content, bool createContinuousSolver /*=  false*/
00070                              )
00071   {
00072     /* Get the basic options. */
00073     readOptionsString(opt_file_content);
00074     /* read nl file by creating AmplTMINLP.*/
00075     Ipopt::SmartPtr<AmplTMINLP> model = new AmplTMINLP(ConstPtr(journalist()), roptions(),
00076                                                 options(), argv, NULL, "bonmin", &nl_file_content);
00077     mayPrintDoc();
00078     toFill.initialize(roptions_, options_, journalist_, prefix(), GetRawPtr(model));
00079     BonminSetup::initialize(toFill, createContinuousSolver);
00080   }
00081 
00083   void BonminAmplSetup::fillOsiInterface(AmplInterface &toFill, char ** &argv, std::string & options,
00084       std::string & nl, bool createContinuousSolver /*=  false*/)
00085   {
00086 
00087     /* Get the basic options. */
00088     readOptionsString(options);
00089     /* Read the model.*/
00090     Ipopt::SmartPtr<AmplTMINLP> model =
00091       new AmplTMINLP(ConstPtr(journalist_),
00092           roptions_,
00093           options_,
00094           argv, NULL, "bonmin", &nl);
00095     toFill.initialize(roptions(), options_, journalist(), prefix(), GetRawPtr(model));
00096   }
00097 
00098 }
00099 

Generated on Thu Sep 22 03:05:53 2011 by  doxygen 1.4.7