BonCouenne.cpp
Go to the documentation of this file.
1 // $Id: BonCouenne.cpp 1270 2019-02-23 17:21:42Z stefan $
2 //
3 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006, 2007
4 // All Rights Reserved.
5 // This code is published under the Eclipse Public License (EPL).
6 //
7 // Authors :
8 // Pietro Belotti, Carnegie Mellon University,
9 // Pierre Bonami, International Business Machines Corporation
10 //
11 // Date : 12/19/2006
12 
13 
14 #include <iomanip>
15 #include <fstream>
16 
17 #include <stdlib.h>
18 
19 #include "CoinPragma.hpp"
20 #include "CoinTime.hpp"
21 #include "CoinError.hpp"
22 #include "BonCouenneInterface.hpp"
23 
24 #include "BonCouenneSetup.hpp"
25 
26 #include "BonCbc.hpp"
27 #include "CouenneBab.hpp"
28 
29 #include "CbcCutGenerator.hpp"
30 #include "CouenneProblem.hpp"
31 #include "CouenneCutGenerator.hpp"
32 
33 #include "CouenneRecordBestSol.hpp"
34 
35 using namespace Couenne;
36 
37 // the maximum difference between a printed optimum and a CouNumber
38 #define PRINTED_PRECISION 1e-5
39 
40 #include "CouenneExprVar.hpp"
41 #include "CouenneExprConst.hpp"
42 #include "CouenneExprSum.hpp"
43 #include "CouenneExprClone.hpp"
44 #include "CouenneProblemElem.hpp"
45 #include "CouenneProblem.hpp"
46 #include "CouenneJournalist.hpp"
47 
48 #ifdef COIN_HAS_NTY
49 #include "Nauty.h"
51 #endif
52 
53 #ifdef COIN_HAS_SCIP
54 #include "lpiswitch.h"
55 #endif
56 
57 #include "CoinSignal.hpp"
58 
59 #undef printError // defined in SCIP, replaces error handling below...
60 
61 #if 0
62 extern "C" {
63 
64  static int nInterrupts = 0;
65  static void signal_handler (int sig) {
66 
67  if (!nInterrupts) {
68  std::cerr << "[BREAK]" << std::endl;
69  abort ();
70  }
71  return;
72  }
73 }
74 #endif
75 
76 //#define FM_FRES
77 
78 // restored working version
79 
80 int main (int argc, char *argv[]) {
81 
82 #ifdef WIN_
83  srand ((long) 42*666);
84 #endif
85 
86  //CoinSighandler_t saveSignal = SIG_DFL;
87  //saveSignal = signal (SIGINT, signal_handler);
88 
89  printf ("\
90 Couenne %s -- an Open-Source solver for Mixed Integer Nonlinear Optimization\n\
91 Mailing list: couenne@list.coin-or.org\n\
92 Instructions: http://www.coin-or.org/Couenne\n",
93  strcmp (COUENNE_VERSION, "trunk") ? COUENNE_VERSION : "");
94 
95  WindowsErrorPopupBlocker();
96 
97  using namespace Ipopt;
98 
99 #ifdef COIN_HAS_SCIP
100  //SCIPlpiSwitchSetDefaultSolver();
101  SCIPlpiSwitchSetSolver(SCIP_LPISW_CLP);
102 #endif
103 
104  char * pbName = NULL;
105 
106  bool infeasible = false;
107 
108  try {
109 
110  CouenneBab bb;
111 
112  CouenneProblem *p = NULL;
113  CouenneInterface *ci = NULL;
114 
115 #if 0
116  //ci = new CouenneInterface;
117  p = new CouenneProblem;
118 
119  p -> addVariable (false, p -> domain ());
120  p -> addVariable (false, p -> domain ());
121  p -> addVariable (false, p -> domain ());
122  p -> addVariable (false, p -> domain ());
123 
124  p -> addObjective (new exprSum (new exprClone (p->Var (1)), new exprClone (p->Var (2))), "min");
125  p -> addLEConstraint (new exprSum (new exprClone (p->Var (0)), new exprClone (p->Var (2))), new exprConst (1));
126  p -> addEQConstraint (new exprSum (new exprClone (p->Var (1)), new exprClone (p->Var (2))), new exprConst (1));
127  p -> addEQConstraint (new exprSum (new exprClone (p->Var (1)), new exprClone (p->Var (3))), new exprConst (1));
128  p -> addEQConstraint (new exprSum (new exprClone (p->Var (2)), new exprClone (p->Var (3))), new exprConst (1));
129 #endif
130 
131  CouenneSetup couenne;
132  CouenneCutGenerator *cg = NULL;
133  ConstJnlstPtr jnlst;
134  CouenneProblem *prob = NULL;
135 
136  infeasible = !(couenne.InitializeCouenne (argv, p, NULL, ci, &bb));
137 
138  // there is only one CouenneCutGenerator object; scan array until
139  // dynamic_cast returns non-NULL
140 
141  if (couenne. cutGenerators () . size () > 0) {
142 
143  for (std::list <Bonmin::BabSetupBase::CuttingMethod>::iterator
144  i = couenne.cutGenerators () . begin ();
145  !cg && (i != couenne.cutGenerators () . end ());
146  ++i)
147 
148  cg = dynamic_cast <CouenneCutGenerator *> (i -> cgl);
149  }
150 
151  // This assumes that first cut generator is CouenneCutGenerator
152  // CouenneCutGenerator *cg = dynamic_cast<CouenneCutGenerator *>
153  // (couenne.cutGenerators().begin()->cgl);
154 
155  if (cg)
156 
157  cg -> setBabPtr (&bb);
158 
159  else if (!infeasible) {
160 
161  printf ("main(): ### ERROR: Can not get CouenneCutGenerator\n");
162  exit (-1);
163  }
164 
165  // initial printout
166 
167  jnlst = couenne. couennePtr () -> Jnlst ();
168  prob = couenne. couennePtr () -> Problem ();
169 
170  bb. setProblem (prob);
171 
172  int retcomp = 2; // unspecified.
173 
174  jnlst -> Printf (J_ERROR, J_COUENNE, "\
175 Loaded instance \"%s\"\n\
176 Constraints: %8d\n\
177 Variables: %8d (%d integer)\n\
178 Auxiliaries: %8d (%d integer)\n\n",
179  prob -> problemName ().c_str (),
180  prob -> nOrigCons (),
181  prob -> nOrigVars (),
182  prob -> nOrigIntVars (),
183  prob -> nVars () - prob -> nOrigVars (),
184  CoinMax (0, prob -> nIntVars () - prob -> nOrigIntVars ()));
185 
186  double time_start = CoinCpuTime();
187 
188 #if 0
189  CouenneFeasibility feasibility;
190  bb.model().setProblemFeasibility (feasibility);
191 #endif
192 
193  couenne.options () -> SetIntegerValue ("bb_log_level", 1);
194  couenne.options () -> SetIntegerValue ("lp_log_level", 0);
195  couenne.options () -> SetIntegerValue ("nlp_log_level", 0);
196 
198  double timeLimit = 0;
199  couenne.options () -> GetNumericValue ("time_limit", timeLimit, "couenne.");
200  couenne.setDoubleParameter (Bonmin::BabSetupBase::MaxTime,
201  CoinMax (1., timeLimit - time_start));
202 
203  //jnlst -> Printf (J_ERROR, J_COUENNE, "Starting branch-and-bound\n");
204 
206 
207 #ifdef COIN_HAS_NTY
208  double symmGroupSize = prob -> orbitalBranching () ? prob -> getNtyInfo () -> getGroupSize () : -1;
209 #endif
210 
211  // run FP and exit if its option is equal to "only"
212 
213  std::string s;
214  couenne.options () -> GetStringValue ("feas_pump_heuristic", s, "couenne.");
215 
216  // if ("only" == s) {
217  // CouenneFeasPump *nlpHeuristic = NULL;
218  // for (std::list<struct Bonmin::BabSetupBase::HeuristicMethod>::iterator i = couenne.heuristics(). begin();
219  // i!=couenne.heuristics(). end() && !nlpHeuristic; ++i) {
220  // nlpHeuristic = dynamic_cast <CouenneFeasPump *> (i -> heuristic);
221  // }
222  // if (!nlpHeuristic) jnlst -> Printf (J_ERROR, J_COUENNE, "Set feas_pump_heuristic to \"once\" but FP not found.\n");
223  // else {
224  // CouNumber
225  // *newsol = new CouNumber [prob -> nVars ()],
226  // objval;
227  // nlpHeuristic -> solution (objval, newsol);
228  // // check solution and saves it
229  // if (! (prob -> checkNLP2 (newsol, 0, false, true, false, prob -> getFeasTol ())))
230  // jnlst -> Printf (J_ERROR, J_COUENNE, "Single run of FP found an infeasible solution\n");
231  // delete [] newsol;
232  // couenne.options () -> SetNumericValue ("time_limit", 0.001, "couenne.");
233  // couenne.setDoubleParameter (Bonmin::BabSetupBase::MaxTime, 0.001);
234  // }
235  // }
236 
237  bool printOptions;
238 
239  std::string liststr;
240  couenne.options () -> PrintUserOptions (liststr);
241  jnlst -> Printf (J_ERROR, J_MAIN, "\nList of user-set options:\n\n%s", liststr.c_str());
242 
243  if (!infeasible) // /|-------------=
244  bb (couenne); // do branch and bound // < | =
245  // \|-------------=
246  else {
247 
248  char *filename = new char [prob -> problemName (). length () + strlen ((char *) ".sol") + 1],
249  *lastdot;
250 
251  FILE *amplsol;
252 
253  strcpy (filename, prob -> problemName () . c_str ());
254 
255  if ((lastdot = strrchr (filename, '.')) != NULL)
256  *lastdot = 0;
257 
258  strcat (filename, ".sol");
259 
260  amplsol = fopen (filename, "w");
261 
262  if (amplsol != NULL) {
263 
264  fprintf (amplsol, "Couenne (%s %s): Infeasible\n\nOptions\n3\n0\n1\n0\n%d\n0\n%d\n0\nobjno 0 220\n",
265  prob -> problemName (). c_str (),
266  __DATE__,
267  prob -> nOrigCons (),
268  prob -> nOrigVars ());
269 
270  fclose (amplsol);
271  }
272 
273  delete [] filename;
274  }
275 
276 #ifdef COIN_HAS_NTY
278  printf ("%d orbital nontrivial branchings\n", CouenneBranchingObject::nOrbBr);
279 #endif
280 
281  std::cout.precision (10);
282 
283  int nr=-1, nt=-1;
284  double st=-1;
285 
286  if (cg) cg -> getStats (nr, nt, st);
287  else printf ("Warning, could not get pointer to CouenneCutGenerator\n");
288 
289  CouenneProblem *cp = cg ? cg -> Problem () : NULL;
290 
291 #if defined (FM_TRACE_OPTSOL) || defined (FM_FRES)
292  double cbcLb = (infeasible ? -COIN_DBL_MAX : bb.model (). getBestPossibleObjValue ());
293  double printObj = 0;
294  bool foundSol = false;
295 #endif
296 
297 #ifdef FM_TRACE_OPTSOL
298 
299  //FILE *fSol = fopen ("bidon.sol", "w");
300 
301  // if(fSol == NULL) {
302  // printf("### ERROR: can not open bidon.sol\n");
303  // exit(1);
304  // }
305 
306  if (cp != NULL) {
307  double cbcObjVal = infeasible ? COIN_DBL_MAX : bb.model().getObjValue();
308  int modelNvars = prob -> nVars ();//bb.model().getNumCols();
309 
311  const double *cbcSol = infeasible ? NULL : bb.model().getColSolution();
312  double *modCbcSol = new double[modelNvars];
313  double modCbcSolVal= 1e100, modCbcSolMaxViol = 0;
314  bool cbcSolIsFeas = false;
315 
316  if(modelNvars != cp->nVars()) {
317  printf("### ERROR: modelNvars: %d nVars: %d\n",
318  modelNvars, cp->nVars());
319  exit(1);
320  }
321 
322  // round cbcSol's integer coordinates
323 
324  // for (int i=0; i<modelNvars; i++)
325  // if (cp -> Var (i) -> isDefinedInteger ())
326  // cbcSol [i] = COUENNE_round (cbcSol [i]);
327 
328  if (cbcObjVal < 1e49 && !infeasible) {
329 
330 #ifdef FM_CHECKNLP2
331  int cMS = rs->getCardModSol();
332  cbcSolIsFeas = cp->checkNLP2(cbcSol, 0, false, // do not care about obj
333  false, // do not stop at first viol
334  true, // checkAll
335  cp->getFeasTol());
336  cMS = rs->getCardModSol(); // re-read in case it changed after checkNLP2 (it could be -1 if no solution present)
337  CoinCopyN(rs->getModSol(cMS), cMS, modCbcSol);
338  modCbcSolVal = rs->getModSolVal();
339  modCbcSolMaxViol = rs->getModSolMaxViol();
340 #else /* not FM_CHECKNLP2 */
341  int cMS = cp->nVars();
342  cbcSolIsFeas = cp->checkNLP(cbcSol, modCbcSolVal, true);
343  CoinCopyN(cbcSol, cMS, modCbcSol);
344  modCbcSolMaxViol = cp->getFeasTol();
345 #endif /* not FM_CHECKNLP2 */
346  foundSol = true;
347  }
348 
349  const double *couenneSol = rs->getSol();
350  double *modCouenneSol = new double[modelNvars];
351  double modCouenneSolVal= 1e100, modCouenneSolMaxViol = 0;
352  bool couenneSolIsFeas = false;
353 
354  // round couenneSol's integer coordinates
355 
356  // for (int i=0; i<modelNvars; i++)
357  // if (cp -> Var (i) -> isDefinedInteger ())
358  // couenneSol [i] = COUENNE_round (couenneSol [i]);
359 
360  if(couenneSol != NULL) {
361 #ifdef FM_CHECKNLP2
362  int cMS = rs->getCardModSol();
363  couenneSolIsFeas = cp->checkNLP2(couenneSol, 0, false,
364  false, true,
365  cp->getFeasTol());
366  CoinCopyN(rs->getModSol(cMS), cMS, modCouenneSol);
367  modCouenneSolVal = rs->getModSolVal();
368  modCouenneSolMaxViol = rs->getModSolMaxViol();
369 #else /* not FM_CHECKNLP2 */
370  int cMS = cp->nVars();
371  couenneSolIsFeas = cp->checkNLP(couenneSol, modCouenneSolVal, true);
372  CoinCopyN(couenneSol, cMS, modCouenneSol);
373  modCouenneSolMaxViol = cp->getFeasTol();
374 #endif /* not FM_CHECKNLP2 */
375  foundSol = true;
376  }
377 
378  retcomp = rs -> compareAndSave (modCbcSol, modCbcSolVal, modCbcSolMaxViol, cbcSolIsFeas,
379  modCouenneSol, modCouenneSolVal, modCouenneSolMaxViol, couenneSolIsFeas,
380  modelNvars, cp->getFeasTol());
381 
382 
383  // rs now has the best and/or least violated solution. Write it out if required
384 
385  std::string saveSol;
386 
387  couenne.options () -> GetStringValue ("save_soltext", saveSol, "couenne.");
388 
389  if (saveSol == "yes") {
390 
391  char *txtFileName = new char [20 + cp -> problemName () . length ()];
392 
393  sprintf (txtFileName, "%s-sol.txt", cp -> problemName (). c_str ());
394 
395  FILE *txtSol = fopen (txtFileName, "w");
396 
397  if (txtSol == NULL) {
398 
399  printf ("Could not create file %s for solving solution\n", txtFileName);
400 
401  } else {
402 
403  cp -> domain () -> push (cp -> nOrigVars (), rs -> getSol (), NULL, NULL);
404 
405  cp -> initAuxs (); // to get auxiliaries in case some of these were previously originals
406 
407  for (std::vector <exprVar *>::iterator it = cp -> Variables (). begin ();
408  it != cp -> Variables(). end (); ++it) {
409 
410  if ((*it) -> Index () >= cp -> nOrigVars ())
411  continue;
412 
413  if ((*it) -> Multiplicity () == 0) {
414 
415  if ((*it) -> Image ()) fprintf (txtSol, "%d %e\n", (*it) -> Index (), (*(*it) -> Image ()) ());
416  else fprintf (txtSol, "%d %e\n", (*it) -> Index (), 0);
417 
418  } else fprintf (txtSol, "%d %e\n", (*it) -> Index (), (*(*it)) ());
419  }
420 
421  cp -> domain () -> pop ();
422  }
423 
424  fclose (txtSol);
425 
426  delete [] txtFileName;
427  }
428 
429  // switch (retcomp) {
430  // case -1: printf("No solution found\n"); break;
431  // case 0: printf("Best solution found by Cbc. Value: %10.4f. Tolerance: %10g\n", modCbcSolVal, modCbcSolMaxViol); break;
432  // case 1: //printf("Best solution found by Couenne Value: %10.4f Tolerance: %10g\n", modCouenneSolVal, modCouenneSolMaxViol); break;
433  // default: break; // never happens
434  // }
435 
436  if(rs->getHasSol()) {
437  if(cbcLb > rs->getVal()) { // Best sol found by Couenne and not
438  // transmitted to Cbc
439  cbcLb = rs->getVal();
440  }
441  printObj = rs->getVal();
442  //rs->printSol(fSol);
443  }
444  delete[] modCbcSol;
445  delete[] modCouenneSol;
446  }
447  //fclose(fSol);
448 #endif /* FM_TRACE_OPTSOL */
449 
450 #ifdef FM_FRES
451  if(cp != NULL) {
452  FILE *f_res = NULL;
453  f_res = fopen("fres.xxx", "r");
454  if(f_res == NULL) {
455  f_res = fopen("fres.xxx", "w");
456  fprintf(f_res, "END_OF_HEADER\n");
457  }
458  else {
459  fclose(f_res);
460  f_res = fopen("fres.xxx", "a");
461  }
462  char *pbName, shortName[256];
463 
464  pbName = strdup(cp -> problemName ().c_str ());
465  char *f_name_pos = strrchr(pbName, '/');
466  if(f_name_pos != NULL) {
467  strcpy(shortName, &(f_name_pos[1]));
468  }
469  else {
470  strcpy(shortName, pbName);
471  }
472 
473 
474  fprintf(f_res, "%20s ", shortName);
475  if((cbcLb > 1e20) || (cbcLb < -1e20)) {
476  fprintf(f_res, "%10.4g", cbcLb);
477  }
478  else {
479  fprintf(f_res, "%10.4f", cbcLb);
480  }
481  if(foundSol) {
482  fprintf(f_res, " %10.4f", printObj);
483  }
484  else {
485  fprintf(f_res, " *");
486  }
487  fprintf(f_res, " %10d %10.4f\n", infeasible ? 0 : bb.numNodes (),
488  CoinCpuTime () - time_start);
489  fclose(f_res);
490  }
491 #endif
492 
493  // save solution to text file
494 
495  // retrieve test value to check
496  double global_opt;
497  couenne.options () -> GetNumericValue ("couenne_check", global_opt, "couenne.");
498 
499  double
500  ub = infeasible ? COIN_DBL_MAX : bb. model (). getObjValue (),
501  lb = infeasible ? -COIN_DBL_MAX : bb. model (). getBestPossibleObjValue ();
502 
503  if (cp -> getRecordBestSol () &&
504  cp -> getRecordBestSol () -> getHasSol () &&
505  (ub > cp -> getRecordBestSol () -> getVal ()))
506  ub = cp -> getRecordBestSol () -> getVal ();
507 
508  if (false || //(fabs (lb) > COUENNE_INFINITY / 1e4) ||
509  (lb > ub))
510  lb = ub;
511 
512  char
513  *gapstr = new char [40],
514  *lbstr = new char [40],
515  *ubstr = new char [40];
516 
517  // CouenneSolverInterface <OsiClpSolverInterface> *csi = dynamic_cast <CouenneSolverInterface *> (couenne.continuousSolver ());
518 
519  // double rootLB = csi -> rootLB ();
520 
521  sprintf (lbstr, "%10g", lb);
522  sprintf (ubstr, "%10g", ub);
523  if(ub > COUENNE_INFINITY/1e4) {
524  sprintf (gapstr, "--");
525  }
526  else {
527  sprintf (gapstr, "%.2f%%", fabs (100. * (ub - lb) / (1. + fabs (lb))));
528  }
529 
530  if (!infeasible)
531  jnlst -> Printf (J_ERROR, J_COUENNE, "\n\
532 Linearization cuts added at root node: %8d\n\
533 Linearization cuts added in total: %8d (separation time: %gs)\n",
534  nr, nt, st);
535 
536  else jnlst -> Printf (J_ERROR, J_COUENNE, "Problem infeasible\n");
537 
538  jnlst -> Printf (J_NONE, J_COUENNE, "\
539 Total solve time: %8gs (%gs in branch-and-bound)\n\
540 Lower bound: %s\n\
541 Upper bound: %s (gap: %s)\n\
542 Branch-and-bound nodes: %8d\n",
543  CoinCpuTime () - time_start,
544  cg ? (CoinCpuTime () - CoinMax (time_start, cg -> rootTime ())) : CoinCpuTime () - time_start,
545  ((lb <= -8.9999e12) ||
546  infeasible || (fabs (lb) > COUENNE_INFINITY/1e4)) ? " -inf" : lbstr,
547  ((retcomp < 0) || infeasible || (ub > COUENNE_INFINITY/1e4)) ? " inf" : ubstr,
548  ( infeasible || (CoinMax (fabs (lb), fabs (ub)) > COUENNE_INFINITY/1e4)) ? "--" : gapstr,
549  infeasible ? 0 : bb.numNodes ());
550 
551  // if (fabs (ub - bb. model (). getObjValue ()) > COUENNE_EPS * fabs (ub))
552  // jnlst -> Printf (J_ERROR, J_COUENNE,
553  // "Warning: upper bounds differ between Couenne and Cbc. Saving Couenne's (more reliable).\n");
554 
555  delete [] lbstr;
556  delete [] ubstr;
557  delete [] gapstr;
558 
559  if (global_opt < COUENNE_INFINITY) { // some value found in couenne.opt
560 
561  double opt = infeasible ? -COIN_DBL_MAX : bb.model (). getBestPossibleObjValue ();
562 
563  printf ("Global Optimum Test on %-40s %s\n",
564  cp ? cp -> problemName ().c_str () : "unknown",
565  (fabs (opt - global_opt) /
566  (1. + CoinMax (fabs (opt), fabs (global_opt))) < PRINTED_PRECISION) ?
567  (const char *) "OK" : (const char *) "FAILED");
568  //opt, global_opt,
569  //fabs (opt - global_opt));
570 
571  } else // good old statistics
572 
573  if (couenne.displayStats ()) { // print statistics
574 
575  if (cg && !cp) printf ("Warning, could not get pointer to problem\n");
576  else
577  printf ("Stats: %-15s %4d [var] %4d [int] %4d [con] %4d [aux] "
578  "%6d [root] %8d [tot] %6g [sep] %8g [time] %8g [bb] "
579 #ifdef COIN_HAS_NTY
580  "%20e [lower] %20e [upper] %7d [nodes] %.0g [sg] %d [sgc]\n",
581 #else
582  "%20e [lower] %20e [upper] %7d [nodes]\n",
583 #endif
584  cp ? cp -> problemName (). c_str () : "unknown",
585  cp ? cp -> nOrigVars () : -1,
586  cp ? cp -> nOrigIntVars () : -1,
587  cp ? cp -> nOrigCons () : -1,
588  cp ? (cp -> nVars () -
589  cp -> nOrigVars ()) : -1,
590  nr, nt, st,
591  CoinCpuTime () - time_start,
592  cg ? (CoinCpuTime () - cg -> rootTime ()) : CoinCpuTime (),
593  lb, //bb.model (). getBestPossibleObjValue (),
594  ub, //bb.model (). getObjValue (),
595  //bb.bestBound (),
596  //bb.bestObj (),
597  infeasible ? 0 : bb.numNodes ()
598 #ifdef COIN_HAS_NTY
599  ,symmGroupSize
601 #endif
602  );
603  //bb.iterationCount ());
604  //status.c_str (), message.c_str ());
605  }
606  }
608  E->writeDiffFiles();
609  E->printError(std::cerr);
610  //There has been a failure to solve a problem with Ipopt.
611  //And we will output file with information on what has been changed in the problem to make it fail.
612  //Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place.
613  // const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver();
614  }
616  std::cerr<<E.className()<<"::"<<E.methodName()
617  <<std::endl
618  <<E.message()<<std::endl;
619  }
620  catch (CoinError &E) {
621  std::cerr<<E.className()<<"::"<<E.methodName()
622  <<std::endl
623  <<E.message()<<std::endl;
624  }
625  catch (Ipopt::OPTION_INVALID &E)
626  {
627  std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
628  }
629  // catch (int generic_error) {
630  // // if (generic_error == infeasible)
631  // // printf ("problem infeasible\n");
632  // }
633 
634 // catch(...) {
635 // std::cerr<<pbName<<" unrecognized excpetion"<<std::endl;
636 // std::cerr<<pbName<<"\t Finished \t exception"<<std::endl;
637 // throw;
638 // }
639 
640  delete [] pbName;
641  return 0;
642 }
Cut Generator for linear convexifications.
int nVars() const
Total number of variables.
#define COUENNE_VERSION
int main(int argc, char *argv[])
Definition: BB_tm.cpp:32
void writeDiffFiles(const std::string prefix=std::string()) const
write files with differences between input model and this one
bool checkNLP2(const double *solution, const double obj, const bool careAboutObj, const bool stopAtFirstViol, const bool checkAll, const double precision) const
Return true if either solution or recomputed_solution obtained using getAuxs() from the original vari...
Definition: checkNLP.cpp:571
constant-type operator
Error class to throw exceptions from OsiTMINLPInterface.
CouenneRecordBestSol * getRecordBestSol() const
returns recorded best solution
fint end
static void signal_handler(int whichSignal)
Definition: BonCbc.cpp:47
Class for MINLP problems with symbolic information.
void printError(std::ostream &os)
Print error message.
expression clone (points to another expression)
#define PRINTED_PRECISION
Definition: BonCouenne.cpp:38
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
exprVar * Var(int i) const
Return pointer to i-th variable.
static const int infeasible
Definition: Couenne.cpp:68
#define COUENNE_INFINITY
We will throw this error when a problem is not solved.
double getFeasTol()
returns feasibility tolerance
fint nt
int numNodes() const
return the total number of nodes explored.
Definition: BonCbc.hpp:67
bool checkNLP(const double *solution, double &obj, bool recompute=false) const
Check if solution is MINLP feasible.
Definition: checkNLP.cpp:23
The in-memory representation of the variables element.
Definition: OSInstance.h:83
const Ipopt::EJournalCategory J_COUENNE(Ipopt::J_USER8)
double * getModSol(const int expectedCard)
const CbcModel & model() const
Get cbc model used to solve.
Definition: BonCbc.hpp:87