/home/coin/SVN-release/OS-2.0.1/Bonmin/src/Algorithms/Branching/BonQpBranchingSolver.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2006, 2008 International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 // Authors: Andreas Waechter, Pierre Bonami
00004 
00005 #include "BonminConfig.h"
00006 
00007 #if defined(_MSC_VER)
00008 // Turn off compiler warning about long names
00009 #  pragma warning(disable:4786)
00010 #endif
00011 #define Verbose
00012 #include "BonQpBranchingSolver.hpp"
00013 
00014 #ifdef COIN_HAS_FILTERSQP
00015 #include "BonFilterSolver.hpp"
00016 #include "BonBqpdSolver.hpp"
00017 #endif
00018 
00019 namespace Bonmin
00020 {
00021 
00022   QpBranchingSolver::QpBranchingSolver(OsiTMINLPInterface * solver)
00023       :
00024       StrongBranchingSolver(solver)
00025   {}
00026 
00027   QpBranchingSolver::QpBranchingSolver(const QpBranchingSolver & rhs) :
00028       StrongBranchingSolver(rhs)
00029   {}
00030 
00031   QpBranchingSolver &
00032   QpBranchingSolver::operator=(const QpBranchingSolver & rhs)
00033   {
00034     if (this != &rhs) {
00035       StrongBranchingSolver::operator=(rhs);
00036     }
00037     return *this;
00038   }
00039 
00040   QpBranchingSolver::~QpBranchingSolver ()
00041   {}
00042 
00043   void QpBranchingSolver::
00044   markHotStart(OsiTMINLPInterface* tminlp_interface)
00045   {
00046     TMINLP2TNLP* tminlp2tnlp = tminlp_interface->problem();
00047     branching_tqp_ = new BranchingTQP(tminlp2tnlp);
00048 
00049     first_solve_ = true;
00050 #ifdef COIN_HAS_FILTERSQP
00051     FilterSolver* filter_solver =
00052       dynamic_cast<FilterSolver*> (tminlp_interface->solver());
00053     if (filter_solver) {
00054       SmartPtr<BqpdSolver> qp_solver_ =
00055         new BqpdSolver(RegOptions(), Options(), Jnlst());
00056 #if 1
00057       // Solve the QP with the original bounds and set the hot start
00058       // information
00059       TNLPSolver::ReturnStatus retstatus;
00060       retstatus = qp_solver_->OptimizeTNLP(GetRawPtr(branching_tqp_));
00061       if (retstatus == TNLPSolver::solvedOptimal ||
00062           retstatus == TNLPSolver::solvedOptimalTol) {
00063         first_solve_ = false;
00064         qp_solver_->markHotStart();
00065       }
00066 #endif
00067       tqp_solver_ = GetRawPtr(qp_solver_);
00068       //tqp_solver_ = new FilterSolver(RegOptions(), Options(), Jnlst());
00069     }
00070 #endif
00071     if (IsNull(tqp_solver_)) {
00072       tqp_solver_ = tminlp_interface->solver()->clone();
00073     }
00074     tqp_solver_->enableWarmStart();
00075   }
00076 
00077   void QpBranchingSolver::
00078   unmarkHotStart(OsiTMINLPInterface* tminlp_interface)
00079   {
00080     // Free memory
00081     branching_tqp_ = NULL;
00082     tqp_solver_ = NULL;
00083   }
00084 
00085   TNLPSolver::ReturnStatus QpBranchingSolver::
00086   solveFromHotStart(OsiTMINLPInterface* tminlp_interface)
00087   {
00088     TNLPSolver::ReturnStatus retstatus;
00089     if (first_solve_) {
00090       retstatus = tqp_solver_->OptimizeTNLP(GetRawPtr(branching_tqp_));
00091     }
00092     else {
00093       retstatus = tqp_solver_->ReOptimizeTNLP(GetRawPtr(branching_tqp_));
00094     }
00095 
00096     if (retstatus == TNLPSolver::solvedOptimal ||
00097         retstatus == TNLPSolver::solvedOptimalTol) {
00098       // don't way we solve the problem, since otherwise the pseudo costs
00099       // are updated and that is maybe not so good???
00100       //retstatus = TNLPSolver::iterationLimit;
00101       first_solve_ = false;
00102     }
00103     //retstatus = TNLPSolver::iterationLimit;
00104     return retstatus;
00105   }
00106 
00107 }

Generated on Thu Oct 8 03:02:54 2009 by  doxygen 1.4.7