00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CbcModel.hpp"
00012 #include "CoinTime.hpp"
00013 #include "CoinHelperFunctions.hpp"
00014
00015 #include "CouenneFeasPump.hpp"
00016 #include "CouenneMINLPInterface.hpp"
00017 #include "CouenneProblem.hpp"
00018 #include "CouenneProblemElem.hpp"
00019 #include "CouenneCutGenerator.hpp"
00020
00021 #include "CouenneTNLP.hpp"
00022
00023 using namespace Ipopt;
00024 using namespace Couenne;
00025
00027 CouNumber CouenneFeasPump::solveNLP (CouNumber *iSol, CouNumber *&nSol) {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 bool firstNLP = (nlp_ == NULL);
00056
00057 if (firstNLP)
00058 nlp_ = new CouenneTNLP (problem_);
00059
00060 problem_ -> domain () -> push (problem_ -> nVars (),
00061 iSol,
00062 NULL,
00063 NULL);
00064
00065
00066
00067 expression
00068 *oldObj = problem_ -> Obj (0) -> Body (),
00069 *newObj = updateNLPObj (iSol);
00070
00071 newObj -> realign (problem_);
00072 problem_ -> setObjective (0, newObj);
00073 nlp_ -> setObjective (newObj);
00074
00075 if (problem_ -> Jnlst () -> ProduceOutput (J_STRONGWARNING, J_NLPHEURISTIC)) {
00076 printf ("now solving NLP:\n");
00077 problem_ -> print ();
00078 printf ("-----------------------\n");
00079 }
00080
00081
00082
00083
00084 nlp_ -> setInitSol (iSol);
00085
00087
00088 ApplicationReturnStatus status = firstNLP ?
00089 app_ -> OptimizeTNLP (nlp_) :
00090 app_ -> ReOptimizeTNLP (nlp_);
00091
00093
00094 if (nlp_ -> getSolution ())
00095
00096 if (nSol) CoinCopyN (nlp_ -> getSolution (), problem_ -> nVars (), nSol);
00097 else nSol = CoinCopyOfArray (nlp_ -> getSolution (), problem_ -> nVars ());
00098
00099 else problem_ -> Jnlst () -> Printf
00100 (J_ERROR, J_NLPHEURISTIC, "FP: warning, NLP returns a NULL solution\n");
00101
00102 delete newObj;
00103
00104 CouNumber retval;
00105
00106 problem_ -> setObjective (0, oldObj);
00107
00108 if ((status != Solve_Succeeded) &&
00109 (status != Solved_To_Acceptable_Level))
00110
00111 problem_ -> Jnlst () -> Printf
00112 (J_ERROR, J_NLPHEURISTIC, "Feasibility Pump: Error solving NLP problem\n");
00113
00114 retval = nlp_ -> getSolValue ();
00115
00116 problem_ -> domain () -> pop ();
00117
00118 return retval;
00119 }