17 #include "CoinPragma.hpp"
18 #include "CoinError.hpp"
19 #include "CoinTime.hpp"
36 #include "CbcCutGenerator.hpp"
41 #include "lpiswitch.h"
53 class RegisteredOptions;
58 class OsiTMINLPInterface;
61 using namespace Couenne;
64 #define PRINTED_PRECISION 1e-5
73 if (argc==3 && strcmp(argv[1],
"-AMPL")==0)
74 options->SetStringValue(
"nlfile", argv[2]);
76 if (argc==3 && strcmp(argv[1],
"-OSIL")==0)
77 options->SetStringValue(
"osilfile", argv[2]);
82 int main (
int argc,
char *argv[]) {
83 WindowsErrorPopupBlocker();
86 SCIPlpiSwitchSetDefaultSolver();
89 double time_start = CoinCpuTime();
114 if (!userinterface && options->GetStringValue(
"nlfile", dummy,
"")) {
120 if (!userinterface && options->GetStringValue(
"osilfile", dummy,
"")) {
125 if (!userinterface) {
126 fprintf(stderr,
"Error: No input file given.\n");
144 bb.setUsingCouenne (
true);
151 double timeLimit = 0;
152 options -> GetNumericValue (
"time_limit", timeLimit,
"couenne.");
162 options -> GetNumericValue (
"couenne_check", global_opt,
"couenne.");
165 double opt = bb.
model (). getBestPossibleObjValue ();
167 jnlst -> Printf(Ipopt::J_SUMMARY,
J_PROBLEM,
"Global Optimum Test on %-40s %s\n",
168 problem -> problemName ().c_str (),
169 (fabs (opt - global_opt) /
179 if (bb.
model (). cutGenerators ())
180 cg = dynamic_cast <CouenneCutGenerator *> (bb.
model (). cutGenerators () [0] -> generator ());
181 if (cg) cg -> getStats (nr,
nt, st);
182 else jnlst -> Printf(Ipopt::J_WARNING,
J_PROBLEM,
"Warning: Could not get pointer to CouenneCutGenerator\n");
184 jnlst -> Printf(Ipopt::J_SUMMARY,
J_PROBLEM,
"Stats: %-15s %4d [var] %4d [int] %4d [con] %4d [aux] "
185 "%6d [root] %8d [tot] %6g [sep] %8g [time] %8g [bb] "
186 "%20e [lower] %20e [upper] %7d [nodes]\n",
187 problem -> problemName ().c_str (),
188 problem -> nOrigVars (),
189 problem -> nOrigIntVars(),
190 problem -> nOrigCons (),
191 problem -> nVars () - problem -> nOrigVars (),
193 CoinCpuTime () - time_start,
194 cg ? (CoinCpuTime () - cg -> rootTime ()) : CoinCpuTime (),
195 bb.
model (). getBestPossibleObjValue (),
196 bb.
model (). getObjValue (),
217 std::cerr<<E.className()<<
"::"<<E.methodName()
219 <<E.message()<<std::endl;
221 }
catch(CoinError &E) {
222 std::cerr<<E.className()<<
"::"<<E.methodName()
224 <<E.message()<<std::endl;
226 }
catch (Ipopt::OPTION_INVALID &E) {
227 std::cerr<<
"Ipopt exception : "<<E.Message()<<std::endl;
229 }
catch (
int generic_error) {
231 jnlst->Printf(Ipopt::J_SUMMARY,
J_PROBLEM,
"problem infeasible\n");
234 delete userinterface;
Cut Generator for linear convexifications.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all Couenne options.
bool displayStats()
true if one wants to display statistics at the end of program
int main(int argc, char *argv[])
void setOptionsAndJournalist(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist)
Set the value for options, output...
bool IsValid(const OSSmartPtr< U > &smart_ptr)
void writeDiffFiles(const std::string prefix=std::string()) const
write files with differences between input model and this one
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
virtual bool addBabPlugins(Bonmin::Bab &bab)
Called after B&B object is setup.
virtual Ipopt::SmartPtr< Bonmin::TMINLP > getTMINLP()=0
Should return the problem to solve as TMINLP.
void initOptions(Ipopt::SmartPtr< Ipopt::OptionsList > options)
initializes parameters like doOBBT
#define PRINTED_PRECISION
Error class to throw exceptions from OsiTMINLPInterface.
void setDoubleParameter(const DoubleParameter &p, const double val)
modify parameter (used for MaxTime)
virtual bool writeSolution(Bonmin::Bab &bab)
Called after B&B finished.
virtual bool setupJournals()
Setup journals for printing.
bool IsNull(const OSSmartPtr< U > &smart_ptr)
virtual CouenneProblem * getCouenneProblem()=0
Should return the problem to solve in algebraic form.
Class for MINLP problems with symbolic information.
void printError(std::ostream &os)
Print error message.
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
static const int infeasible
We will throw this error when a problem is not solved.
bool InitializeCouenne(char **argv=NULL, CouenneProblem *couenneProb=NULL, Ipopt::SmartPtr< Bonmin::TMINLP > tminlp=NULL, CouenneInterface *ci=NULL, Bonmin::Bab *bb=NULL)
Initialize from command line arguments.
int numNodes() const
return the total number of nodes explored.
const Ipopt::EJournalCategory J_PROBLEM(Ipopt::J_USER4)
bool parseCommandLine(int argc, char *argv[], Ipopt::SmartPtr< Ipopt::OptionsList > options)
const CbcModel & model() const
Get cbc model used to solve.
Class to add a few more information to Ipopt::RegisteredOptions.