Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneMINLPInterface.hpp
Go to the documentation of this file.
1 /* $Id: CouenneMINLPInterface.hpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: CouenneMINLPInterface
4  * Author: Pietro Belotti
5  * Purpose: MINLP interface with computation of gradient and Jacobian
6  * through CouenneExpressions
7  *
8  * (C) Pietro Belotti 2010
9  * This file is licensed under the Eclipse Public License (EPL)
10  */
11 
12 #ifndef CouenneMINLPInterface_hpp
13 #define CouenneMINLPInterface_hpp
14 
15 //#define INT_BIAS 0e-8
16 
17 //#include <string>
18 //#include <iostream>
19 
20 #include "OsiSolverInterface.hpp"
21 
22 // #include "CoinWarmStartBasis.hpp"
23 
24 // #include "BonTMINLP.hpp"
25 // #include "BonTMINLP2TNLP.hpp"
26 // #include "BonTNLP2FPNLP.hpp"
27 //#include "BonTNLPSolver.hpp"
28 //#include "BonCutStrengthener.hpp"
29 //#include "BonRegisteredOptions.hpp"
30 
31 #include "CouenneTypes.hpp"
32 
33 namespace Ipopt {
34  class OptionsList;
35 }
36 
37 namespace Couenne {
38 
39  class expression;
40  class CouenneProblem;
41 
42  //class RegisteredOptions;
43  //class StrongBranchingSolver;
44 
46 
47  enum Solver {
48  EIpopt=0,
51  };
52 
54 
58 
59  class CouenneMINLPInterface: public OsiSolverInterface {
60 
61  public:
62 
65  void setObj (int index, expression *newObj) {}
66 
68  void setInitSol (const CouNumber *sol);
69 
72  CouNumber solve (CouNumber *solution);
73 
76  {return problem_;}
77 
79  Ipopt::OptionsList *options () const
80  {return options_;}
81 
82  private:
83 
86 
88  Ipopt::OptionsList *options_;
89 
91  virtual std::string appName ()
92  {return "couenne";}
93 
94 
95 #if 0
96  //friend class BonminParam;
97 
98  public:
99 
100  // /// Error class to throw exceptions from CouenneMINLPInterface.
101  // * Inherited from CoinError, we just want to have a different class to be able to catch
102  // * errors thrown by CouenneMINLPInterface.
103  //
104 
105  // class SimpleError: public CoinError {
106 
107  // private:
108  // SimpleError();
109 
110  // public:
111  // ///Alternate constructor using strings
112  // SimpleError(std::string message,
113  // std::string methodName,
114  // std::string f = std::string(),
115  // int l = -1):
116  // CoinError(message,methodName,std::string("CouenneMINLPInterface"), f, l) {}
117  // };
118 
119  // #ifdef __LINE__
120  // #define SimpleError(x, y) SimpleError((x), (y), __FILE__, __LINE__)
121  // #endif
122 
123  // // Error when problem is not solved
124  // TNLPSolver::UnsolvedError * newUnsolvedError(int num, Ipopt::SmartPtr<TMINLP2TNLP> problem, std::string name){
125  // return app_ -> newUnsolvedError (num, problem, name);
126  // }
127  // //#############################################################################
128 
129 
130  // /// Type of the messages specifically outputed by CouenneMINLPInterface.
131  // enum MessagesTypes{
132  // SOLUTION_FOUND///found a feasible solution,
133  // INFEASIBLE_SOLUTION_FOUND///found an infeasible problem,
134  // UNSOLVED_PROBLEM_FOUND///found an unsolved problem,
135  // WARNING_RESOLVING /// Warn that a problem is resolved,
136  // WARN_SUCCESS_WS/// Problem not solved with warm start but solved without,
137  // WARN_SUCCESS_RANDOM/// Subproblem not solve with warm start but solved with random point,
138  // WARN_CONTINUING_ON_FAILURE/// a failure occured but is continuing,
139  // SUSPECT_PROBLEM/// Output the number of the problem.,
140  // SUSPECT_PROBLEM2/// Output the number of the problem.,
141  // IPOPT_SUMMARY /// Output summary statistics on Ipopt solution.,
142  // BETTER_SOL /// Found a better solution with random values.,
143  // LOG_HEAD/// Head of "civilized" log.,
144  // LOG_FIRST_LINE/// First line (first solve) of log.,
145  // LOG_LINE///standard line (retry solving) of log.,
146  // ALTERNATE_OBJECTIVE/// Recomputed integer feasible with alternate objective function,
147  // WARN_RESOLVE_BEFORE_INITIAL_SOLVE /// resolve() has been called but there
148  // was no previous call to initialSolve().
149  // ,
150  // ERROR_NO_TNLPSOLVER /// Trying to access non-existent TNLPSolver,
151  // WARNING_NON_CONVEX_OA /// Warn that there are equality or ranged constraints and OA may works bad.,
152  // SOLVER_DISAGREE_STATUS /// Different solver gives different status for problem.,
153  // SOLVER_DISAGREE_VALUE /// Different solver gives different optimal value for problem.,
154  // OSITMINLPINTERFACE_DUMMY_END
155  // };
156 
157  //#############################################################################
158 
159 
160  // /// Messages outputed by an CouenneMINLPInterface.
161  // class Messages : public CoinMessages
162  // {
163  // public:
164  // /// Constructor
165  // Messages();
166  // };
167 
168 
169  //#############################################################################
170 
171 
173 
176 
178  void initialize(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
181  Ipopt::SmartPtr<TMINLP> tminlp);
182 
184  void setModel(Ipopt::SmartPtr<TMINLP> tminlp);
185 
187  void setSolver(Ipopt::SmartPtr<TNLPSolver> app);
188 
190  void use(Ipopt::SmartPtr<TMINLP2TNLP> tminlp2tnlp){
191  problem_ = tminlp2tnlp;}
192 
194  CouenneMINLPInterface (const CouenneMINLPInterface &);
195 
197  OsiSolverInterface * clone (bool copyData = true) const;
198 
200  CouenneMINLPInterface & operator=(const CouenneMINLPInterface& rhs);
201 
203  virtual ~CouenneMINLPInterface ();
204 
206  void readOptionFile(const std::string & fileName);
207 
210 
213 
214  //---------------------------------------------------------------------------
216 
217  virtual void initialSolve();
219 
225 
226  virtual void resolve();
227 
231 
232  virtual void resolveForCost(int numretry, bool keepWs);
233 
236 
237  virtual void resolveForRobustness(int numretry);
238 
240  virtual void branchAndBound()
241  {
242  //throw SimpleError ("Function not implemented for CouenneMINLPInterface","branchAndBound()");
243  }
245 
246 
247  //---------------------------------------------------------------------------
249 
250 
251  virtual bool isAbandoned () const;
252  virtual bool isProvenOptimal () const;
253  virtual bool isProvenPrimalInfeasible () const;
254  virtual bool isProvenDualInfeasible () const;
255  virtual bool isPrimalObjectiveLimitReached () const;
256  virtual bool isDualObjectiveLimitReached () const;
257  virtual bool isIterationLimitReached () const;
258 
260  void continuingOnAFailure()
261  {
262  hasContinuedAfterNlpFailure_ = true;
263  }
264 
266  bool hasContinuedOnAFailure()
267  {
268  return hasContinuedAfterNlpFailure_;
269  }
270 
272  void ignoreFailures()
273  {
274  pretendFailIsInfeasible_ = 2;
275  }
276 
278  void forceInfeasible()
279  {
280  problem_->set_obj_value(1e200);
281  }
282 
284  void forceBranchable()
285  {
286  problem_->set_obj_value(-1e200);
287  problem_->force_fractionnal_sol();
288  }
290 
291 
292  //---------------------------------------------------------------------------
294 
302 
306 
308  // Set an integer parameter
309  bool setIntParam(OsiIntParam key, int value);
310  // Set an double parameter
311  bool setDblParam(OsiDblParam key, double value);
312  // Set a string parameter
313  bool setStrParam(OsiStrParam key, const std::string & value);
314  // Get an integer parameter
315  bool getIntParam(OsiIntParam key, int& value) const;
316  // Get an double parameter
317  bool getDblParam(OsiDblParam key, double& value) const;
318  // Get a string parameter
319  bool getStrParam(OsiStrParam key, std::string& value) const;
320 
321  // Get the push values for starting point
322  inline double getPushFact() const
323  {
324  return pushValue_;
325  }
326 
328 
329 
330  //---------------------------------------------------------------------------
332 
333  // These methods call the solver's query routines to return
334  // information about the problem referred to by the current object.
335  // Querying a problem that has no data associated with it result in
336  // zeros for the number of rows and columns, and NULL pointers from
337  // the methods that return vectors.
338 
339  // Const pointers returned from any data-query method are valid as
340  // long as the data is unchanged and the solver is not called.
341 
343 
345  virtual int getNumCols() const;
347 
349  virtual int getNumRows() const;
350 
352  const OsiSolverInterface::OsiNameVec& getVarNames() ;
354  virtual const double * getColLower() const;
355 
357  virtual const double * getColUpper() const;
358 
360  // <ul>
361  // <li>'L': <= constraint
362  // <li>'E': = constraint
363  // <li>'G': >= constraint
364  // <li>'R': ranged constraint
365  // <li>'N': free constraint
366  // </ul>
367 
368  virtual const char * getRowSense() const;
369 
371  // <ul>
372  // <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
373  // <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
374  // <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
375  // <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0
376  // </ul>
377 
378  virtual const double * getRightHandSide() const;
379 
381  // <ul>
382  // <li> if rowsense()[i] == 'R' then
383  // rowrange()[i] == rowupper()[i] - rowlower()[i]
384  // <li> if rowsense()[i] != 'R' then
385  // rowrange()[i] is 0.0
386  // </ul>
387 
388  virtual const double * getRowRange() const;
389 
391  virtual const double * getRowLower() const;
392 
394  virtual const double * getRowUpper() const;
395 
398  virtual double getObjSense() const
399  {
400  return 1;
401  }
402 
404  virtual bool isContinuous(int colNumber) const;
405 
407  virtual bool isBinary(int columnNumber) const;
408 
412  virtual bool isInteger (int columnNumber) const;
413 
415  virtual bool isIntegerNonBinary(int columnNumber) const;
416 
418  virtual bool isFreeBinary(int columnNumber) const;
419 
421  virtual double getInfinity() const;
422 
424  const int * getPriorities() const
425  {
426  const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
427  if(branch)
428  return branch->priorities;
429  else return NULL;
430  }
431 
433  const int * getBranchingDirections() const
434  {
435  const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
436  if(branch)
437  return branch->branchingDirections;
438  else return NULL;
439  }
440 
441  const double * getUpPsCosts() const
442  {
443  const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
444  if(branch)
445  return branch->upPsCosts;
446  else return NULL;
447  }
448 
449  const double * getDownPsCosts() const
450  {
451  const TMINLP::BranchingInfo * branch = tminlp_->branchingInfo();
452  if(branch)
453  return branch->downPsCosts;
454  else return NULL;
455  }
456 
458 
460 
461 
463  virtual const double * getColSolution() const;
464 
466  virtual const double * getRowPrice() const;
467 
469  virtual const double * getReducedCost() const;
470 
473  virtual const double * getRowActivity() const;
474 
475 
480 
481  virtual int getIterationCount () const;
482 
484  int nCallOptimizeTNLP()
485  {
486  return nCallOptimizeTNLP_;
487  }
488 
490  double totalNlpSolveTime()
491  {
492  return totalNlpSolveTime_;
493  }
494 
496  int totalIterations()
497  {
498  return totalIterations_;
499  }
500 
501 
503 
504  //-------------------------------------------------------------------------
506 
508 
511  virtual void setColLower( int elementIndex, double elementValue );
512 
515  virtual void setColUpper( int elementIndex, double elementValue );
516 
519 
520  virtual void setColLower(const double * array);
521 
524 
525  virtual void setColUpper(const double * array);
526 
527 
530  virtual void setRowLower( int elementIndex, double elementValue );
531 
533  virtual void setRowUpper( int elementIndex, double elementValue );
534 
536  virtual void setRowType(int index, char sense, double rightHandSide,
537  double range);
538 
539 
544  virtual void setObjSense(double s);
545 
549 
550  virtual void setColSolution(const double *colsol);
551 
555 
556  virtual void setRowPrice(const double * rowprice);
557 
559 
560 
561  //---------------------------------------------------------------------------
563 
564 
566 
571 
572  virtual CoinWarmStart *getEmptyWarmStart () const;
573 
575  virtual CoinWarmStart* getWarmStart() const;
576 
579  virtual bool setWarmStart(const CoinWarmStart* warmstart);
580 
581  void setExposeWarmStart(bool value) {
582  exposeWarmStart_ = value;
583  }
584 
585  bool getExposeWarmStart() {
586  return exposeWarmStart_;
587  }
588 
589  void randomStartingPoint();
590 
591  //Returns true if a basis is available
592  virtual bool basisIsAvailable() const
593  {
594  // Throw an exception
595  throw SimpleError("Needs coding for this interface", "basisIsAvailable");
596  }
597 
598 
600 
601  //-------------------------------------------------------------------------
603 
604  virtual void setContinuous(int index);
607  virtual void setInteger(int index);
609 
610  //Set numIterationSuspect_
611  void setNumIterationSuspect(int value)
612  {
613  numIterationSuspect_ = value;
614  }
615 
622 
623 
625 
626  virtual int getNumElements() const
627  {
628  return -1;
629  }
630 
631 
635 
636  virtual const double * getObjCoefficients() const;
637 
639 
640  virtual const CoinPackedMatrix * getMatrixByRow() const
641  {
642  return NULL;
643  }
644 
645 
647 
648  virtual const CoinPackedMatrix * getMatrixByCol() const
649  {
650  return NULL;
651  }
652 
654 
655  virtual void setObjCoeff( int elementIndex, double elementValue )
656  {
657  throw SimpleError("CouenneMINLPInterface does not implement this function.",
658  "setObjCoeff");
659  }
660 
662 
663  virtual void addCol(const CoinPackedVectorBase& vec,
664  const double collb, const double colub,
665  const double obj)
666  {
667  throw SimpleError("CouenneMINLPInterface does not implement this function.",
668  "addCol");
669  }
670 
672 
673  virtual void deleteCols(const int num, const int * colIndices)
674  {
675  throw SimpleError("CouenneMINLPInterface does not implement this function.",
676  "deleteCols");
677  }
678 
680 
681  virtual void addRow(const CoinPackedVectorBase& vec,
682  const double rowlb, const double rowub)
683  {
684  throw SimpleError("CouenneMINLPInterface does not implement this function.",
685  "addRow");
686  }
687 
689 
690  virtual void addRow(const CoinPackedVectorBase& vec,
691  const char rowsen, const double rowrhs,
692  const double rowrng)
693  {
694  throw SimpleError("CouenneMINLPInterface model does not implement this function.",
695  "addRow");
696  }
698 
699  virtual void deleteRows(const int num, const int * rowIndices)
700  {
701  if(num)
702  freeCachedRowRim();
703  problem_->removeCuts(num, rowIndices);
704  }
705 
706 
708 
709  virtual void loadProblem(const CoinPackedMatrix& matrix,
710  const double* collb, const double* colub,
711  const double* obj,
712  const double* rowlb, const double* rowub)
713  {
714  throw SimpleError("CouenneMINLPInterface does not implement this function.",
715  "loadProblem");
716  }
717 
718 
720 
721  virtual void assignProblem(CoinPackedMatrix*& matrix,
722  double*& collb, double*& colub, double*& obj,
723  double*& rowlb, double*& rowub)
724  {
725  throw SimpleError("CouenneMINLPInterface does not implement this function.",
726  "assignProblem");
727  }
728 
730 
731  virtual void loadProblem(const CoinPackedMatrix& matrix,
732  const double* collb, const double* colub,
733  const double* obj,
734  const char* rowsen, const double* rowrhs,
735  const double* rowrng)
736  {
737  throw SimpleError("CouenneMINLPInterface does not implement this function.",
738  "loadProblem");
739  }
740 
742 
743  virtual void assignProblem(CoinPackedMatrix*& matrix,
744  double*& collb, double*& colub, double*& obj,
745  char*& rowsen, double*& rowrhs,
746  double*& rowrng)
747  {
748  throw SimpleError("CouenneMINLPInterface does not implement this function.",
749  "assignProblem");
750  }
751 
752 
754 
755  virtual void loadProblem(const int numcols, const int numrows,
756  const int* start, const int* index,
757  const double* value,
758  const double* collb, const double* colub,
759  const double* obj,
760  const double* rowlb, const double* rowub)
761  {
762  throw SimpleError("CouenneMINLPInterface does not implement this function.",
763  "loadProblem");
764  }
765 
767 
768  virtual void loadProblem(const int numcols, const int numrows,
769  const int* start, const int* index,
770  const double* value,
771  const double* collb, const double* colub,
772  const double* obj,
773  const char* rowsen, const double* rowrhs,
774  const double* rowrng)
775  {
776  throw SimpleError("CouenneMINLPInterface model does not implement this function.",
777  "loadProblem");
778  }
779 
781 
782  virtual int readMps(const char *filename,
783  const char *extension = "mps")
784  {
785  throw SimpleError("CouenneMINLPInterface does not implement this function.",
786  "readMps");
787  }
788 
789 
791 
792  virtual void writeMps(const char *filename,
793  const char *extension = "mps",
794  double objSense=0.0) const
795  {
796  throw SimpleError("CouenneMINLPInterface does not implement this function.",
797  "writeMps");
798  }
799 
801  virtual std::vector<double*> getDualRays(int maxNumRays) const
802  {
803  throw SimpleError("CouenneMINLPInterface does not implement this function.",
804  "getDualRays");
805  }
806 
808  virtual std::vector<double*> getPrimalRays(int maxNumRays) const
809  {
810  throw SimpleError("CouenneMINLPInterface does not implement this function.",
811  "getPrimalRays");
812  }
813 
815 
816 
817 
818  //---------------------------------------------------------------------------
819 
820 
821 
823 
825  void turnOffSolverOutput(){
826  app_->turnOffOutput();}
827  void turnOnSolverOutput(){
828  app_->turnOnOutput();}
830 
832 
833  virtual double getObjValue() const;
835 
837 
839  const TMINLP2TNLP * problem() const
840  {
841  return GetRawPtr(problem_);
842  }
843 
844  TMINLP2TNLP * problem()
845  {
846  return GetRawPtr(problem_);
847  }
848 
849  const TMINLP * model() const
850  {
851  return GetRawPtr(tminlp_);
852  }
853 
854  Bonmin::TMINLP * model()
855  {
856  return GetRawPtr(tminlp_);
857  }
858 
859  const Bonmin::TNLPSolver * solver() const
860  {
861  return GetRawPtr(app_);
862  }
863 
864  TNLPSolver * solver()
865  {
866  return GetRawPtr(app_);
867  }
869 
870 
872 
876  virtual void extractLinearRelaxation(OsiSolverInterface &si, const double *x,
877  bool getObj = 1);
878 
882 
883  virtual void extractLinearRelaxation(OsiSolverInterface &si, bool getObj = 1,
884  bool solveNlp = 1){
885  if(solveNlp)
886  initialSolve();
887  extractLinearRelaxation(si, getColSolution(), getObj);
888  if(solveNlp){
889  app_->enableWarmStart();
890  setColSolution(problem()->x_sol());
891  setRowPrice(problem()->duals_sol());
892  }
893  }
894 
898  void getOuterApproximation(OsiCuts &cs, bool getObj, const double * x2, bool global)
899  {
900  getOuterApproximation(cs, getColSolution(), getObj, x2, global);
901  }
902 
906  void getOuterApproximation(OsiCuts &cs, const double * x, bool getObj, const double * x2, bool global){
907  getOuterApproximation(cs, x, getObj, x2, 0., global);}
908 
912  virtual void getOuterApproximation(OsiCuts &cs, const double * x, bool getObj, const double * x2,
913  double theta, bool global);
914 
916  virtual void getConstraintOuterApproximation(OsiCuts & cs, int constraintNumber,
917  const double * x,
918  const double * x2, bool global);
919 
921  void getConstraintOuterApproximation(OsiCuts & cs, int constraintNumber,
922  const double * x2, bool global){
923  getConstraintOuterApproximation(cs, constraintNumber, getColSolution(),x2,global);
924  }
925 
927  void getBendersCut(OsiCuts &cs, const double * x, const double *lambda, bool getObj = 1);
928 
936  double getFeasibilityOuterApproximation(int n, const double * x_bar,const int *ind, OsiCuts &cs, bool addOnlyViolated, bool global);
937 
946 
947  double solveFeasibilityProblem(int n, const double * x_bar, const int* ind, double a, double s, int L);
948 
956 
957  double solveFeasibilityProblem(int n, const double * x_bar, const int* ind, int L, double cutoff);
958 
961  void switchToFeasibilityProblem(int n, const double * x_bar, const int* ind, double a, double s, int L);
962 
965  void switchToFeasibilityProblem(int n, const double * x_bar, const int* ind,
966  double rhs_local_branching_constraint);
967 
969  void switchToOriginalProblem();
971 
974 
975  enum OaMessagesTypes {
977  CUT_NOT_VIOLATED_ENOUGH = 0,
978  VIOLATED_OA_CUT_GENERATED,
979  OA_CUT_GENERATED,
980  OA_MESSAGES_DUMMY_END
981  };
982 
984  class OaMessages :public CoinMessages{
985  public:
987  OaMessages();
988  };
989 
991  class OaMessageHandler : public CoinMessageHandler{
992  public:
994  OaMessageHandler():CoinMessageHandler(){
995  }
997  OaMessageHandler(FILE * fp):CoinMessageHandler(fp){
998  }
1000  virtual ~OaMessageHandler(){
1001  }
1003  OaMessageHandler(const OaMessageHandler &other):
1004  CoinMessageHandler(other){}
1006  OaMessageHandler(const CoinMessageHandler &other):
1007  CoinMessageHandler(other){}
1009  OaMessageHandler & operator=(const OaMessageHandler &rhs){
1010  CoinMessageHandler::operator=(rhs);
1011  return *this;}
1013  virtual CoinMessageHandler* clone() const{
1014  return new OaMessageHandler(*this);}
1016  void print(OsiRowCut &row);
1017  };
1018 
1019  void setOaMessageHandler(const CoinMessageHandler &handler){
1020  delete oaHandler_;
1021  oaHandler_ = new OaMessageHandler(handler);
1022  }
1024 
1025  //-----------------------------------------------------------------------
1027 
1028  virtual ApplyCutsReturnCode applyCuts(const OsiCuts & cs,
1029  double effectivenessLb = 0.0){
1030  freeCachedRowRim();
1031  problem_->addCuts(cs);
1032  ApplyCutsReturnCode rc;
1033  return rc;}
1034 
1036  virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
1037 
1038 
1040  virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts)
1041  {
1042  if(numberCuts)
1043  freeCachedRowRim();
1044  problem_->addCuts(numberCuts, cuts);
1045  }
1046 
1048  obj the objective value of x.
1049  double getConstraintsViolation(const double * x, double & obj);
1050 
1052  value where obj is the estimated objective value of x.
1053  double getNonLinearitiesViolation(const double *x, const double obj);
1054 
1055  //---------------------------------------------------------------------------
1056 
1057  void extractInterfaceParams();
1058 
1059 
1061  virtual void setAppDefaultOptions(Ipopt::SmartPtr<Ipopt::OptionsList> Options);
1062 
1064  static void registerOptions (Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
1065 
1067  if(IsValid(app_))
1068  return app_->roptions();
1069  else
1070  return NULL;
1071  }
1072 
1074 
1075  void SetStrongBrachingSolver(Ipopt::SmartPtr<StrongBranchingSolver> strong_branching_solver);
1079  virtual void markHotStart();
1083  virtual void solveFromHotStart();
1086  virtual void unmarkHotStart();
1088 
1089  protected:
1090 
1092 
1093  enum RandomGenerationType{
1094  uniform =0, perturb=1, perturb_suffix=2};
1096  int initializeJacobianArrays();
1097 
1099 
1101 
1103  void solveAndCheckErrors(bool doResolve, bool throwOnFailure,
1104  const char * whereFrom);
1105 
1106 
1108 
1109  virtual void applyRowCut( const OsiRowCut & rc )
1110  {
1111  const OsiRowCut * cut = &rc;
1112  problem_->addCuts(1, &cut);
1113  }
1115 
1116  virtual void applyColCut( const OsiColCut & cc )
1117  {
1118  throw SimpleError("Ipopt model does not implement this function.",
1119  "applyColCut");
1120  }
1121 
1122  // /// Read the name of the variables in an ampl .col file.
1123  // void readVarNames() const;
1124 
1126 
1128 
1129  Ipopt::SmartPtr<TMINLP> tminlp_;
1134  Ipopt::SmartPtr<Ipopt::TNLP> problem_to_optimize_;
1136  bool feasibility_mode_;
1139 
1141  std::list<Ipopt::SmartPtr<TNLPSolver> > debug_apps_;
1143  bool testOthers_;
1145 
1147  CoinWarmStart* warmstart_;
1148 
1150 
1151  void freeCachedColRim();
1154  void freeCachedRowRim();
1156  void freeCachedData();
1159  void extractSenseRhsAndRange() const;
1161  mutable char *rowsense_;
1162 
1164  mutable double *rhs_;
1165 
1167  mutable double *rowrange_;
1170  mutable double *reducedCosts_;
1172  double OsiDualObjectiveLimit_;
1174  mutable bool hasVarNamesFile_;
1176  int nCallOptimizeTNLP_;
1179  double totalNlpSolveTime_;
1181  int totalIterations_;
1183  double maxRandomRadius_;
1185  int randomGenerationType_;
1187  double max_perturbation_;
1189  double pushValue_;
1191  int numRetryInitial_;
1193  int numRetryResolve_;
1195  int numRetryInfeasibles_;
1197  int numRetryUnsolved_;
1199  Messages messages_;
1203  int pretendFailIsInfeasible_;
1205  bool hasContinuedAfterNlpFailure_;
1208  int numIterationSuspect_ ;
1212  bool hasBeenOptimized_;
1216  mutable double * obj_;
1218  static bool hasPrintedOptions;
1219 
1221  Ipopt::SmartPtr<TNLP2FPNLP> feasibilityProblem_;
1222 
1223 
1225 
1226  int * jRow_;
1229  int * jCol_;
1231  double * jValues_;
1233  int nnz_jac;
1235 
1237  Ipopt::TNLP::LinearityType * constTypes_;
1239 
1240  int nNonLinear_;
1242  double tiny_;
1244  double veryTiny_;
1246  double infty_;
1248  TNLPSolver::ReturnStatus optimizationStatus_;
1250  bool exposeWarmStart_;
1252  bool firstSolve_;
1254  SmartPtr<CutStrengthener> cutStrengthener_;
1255 
1258 
1259  OaMessages oaMessages_;
1262  OaMessageHandler * oaHandler_;
1264  protected:
1266  void createApplication(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions,
1270  CouenneMINLPInterface(Ipopt::SmartPtr<TNLPSolver> app);
1271 
1273  bool internal_setWarmStart(const CoinWarmStart* ws);
1274 
1276  CoinWarmStart* internal_getWarmStart() const;
1277  private:
1279  SmartPtr<StrongBranchingSolver> strong_branching_solver_;
1281  TNLPSolver::ReturnStatus optimizationStatusBeforeHotStart_;
1282  static const char * OPT_SYMB;
1283  static const char * FAILED_SYMB;
1284  static const char * INFEAS_SYMB;
1285  static const char * UNBOUND_SYMB;
1287  const char * statusAsString(TNLPSolver::ReturnStatus r){
1288  if(r == TNLPSolver::solvedOptimal || r == TNLPSolver::solvedOptimalTol){
1289  return OPT_SYMB;}
1290  else if(r == TNLPSolver::provenInfeasible){
1291  return INFEAS_SYMB;}
1292  else if(r == TNLPSolver::unbounded){
1293  return UNBOUND_SYMB;}
1294  else return FAILED_SYMB;
1295  }
1296  const char * statusAsString(){
1297  return statusAsString(optimizationStatus_);}
1298 #endif
1299  };
1300 }
1301 
1302 #endif
1303 
void setObj(int index, expression *newObj)
REMOVE — backward compatibility sets objective[index] at newObj.
Ipopt interior point algorithm
CouenneProblem * problem() const
return pointer to Couenne problem
Solver
Solvers for solving nonlinear programs.
Ipopt::OptionsList * options_
Options.
Ipopt::OptionsList * options() const
return pointer to options
filterSQP Sequential Quadratic Programming algorithm
virtual std::string appName()
Virtual callback for application specific stuff.
Use all solvers.
Class for MINLP problems with symbolic information.
double CouNumber
main number type in Couenne
void setInitSol(const CouNumber *sol)
sets the initial solution for the NLP solver
Expression base class.
CouenneProblem * problem_
Symbolic representation of the problem.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
CouNumber solve(CouNumber *solution)
solves and returns the optimal objective function and the solution
bool isInteger(CouNumber x)
is this number integer?