/home/coin/SVN-release/OS-2.4.1/Bonmin/src/Interfaces/Ipopt/BonIpoptWarmStart.cpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, Carnegie Mellon University,
00007 // Andreas Waechter, International Business Machines Corporation
00008 //
00009 // Date : 02/15/2006
00010 
00011 #include "BonIpoptWarmStart.hpp"
00012 #include "CoinHelperFunctions.hpp"
00013 
00014 #include "BonTMINLP2TNLP.hpp"
00015 #include "BonIpoptInteriorWarmStarter.hpp"
00016 
00017 using namespace Ipopt;
00018 
00019 namespace Bonmin
00020 {
00022   IpoptWarmStart::IpoptWarmStart
00023   (bool empty, int numvars, int numcont):
00024       CoinWarmStartPrimalDual(),
00025       CoinWarmStartBasis(),
00026       warm_starter_(NULL),
00027       empty_(empty)
00028   {
00029     setSize(numvars,numcont);
00030   }
00032   IpoptWarmStart::IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
00033       SmartPtr<IpoptInteriorWarmStarter> warm_starter):
00034       CoinWarmStartPrimalDual(tnlp->num_variables(),
00035                               2*tnlp->num_variables()+tnlp->num_constraints(),
00036                               tnlp->x_sol(), tnlp->duals_sol() ),
00037       CoinWarmStartBasis(),
00038       warm_starter_(warm_starter),
00039       empty_(false)
00040   {
00041     int numcols = tnlp->num_variables();
00042     int numrows = tnlp->num_constraints();
00043     // initialize the size in the CoinWarmStartBasis part
00044     setSize(numcols,numrows);
00045   }
00046 
00048 IpoptWarmStart::IpoptWarmStart(int primal_size, int dual_size,
00049                    const double * primal, const double * dual):
00050           CoinWarmStartPrimalDual(primal_size, dual_size, primal, dual),
00051           CoinWarmStartBasis(),
00052           warm_starter_(NULL), 
00053           empty_(false)
00054 {
00055    setSize(primal_size, dual_size - 2* primal_size);
00056 }
00058   IpoptWarmStart::IpoptWarmStart( const IpoptWarmStart &other, bool ownValues):
00059     CoinWarmStartPrimalDual(other),
00060     CoinWarmStartBasis(other),
00061     warm_starter_(NULL /*other.warm_starter_*/),
00062     empty_(other.empty_)
00063   {
00064     //  if(ownValues_ && other.values_ != NULL)
00065   }
00066 
00068   IpoptWarmStart::IpoptWarmStart(const CoinWarmStartPrimalDual& pdws) :
00069     CoinWarmStartPrimalDual(pdws),
00070     CoinWarmStartBasis(),
00071     warm_starter_(NULL),
00072     empty_(false)
00073   {   
00074   }
00075   
00076   CoinWarmStartDiff*
00077   IpoptWarmStart::generateDiff(const CoinWarmStart *const oldCWS) const
00078   {
00079     const IpoptWarmStart * const ws =
00080       dynamic_cast< const IpoptWarmStart * const > (oldCWS);
00081     DBG_ASSERT(ws);
00082 
00083     CoinWarmStartDiff * diff = CoinWarmStartPrimalDual::generateDiff(ws);
00084 
00085     CoinWarmStartPrimalDualDiff * pdDiff =
00086       dynamic_cast<CoinWarmStartPrimalDualDiff*>(diff);
00087 
00088     CoinWarmStartDiff* retval =
00089       new IpoptWarmStartDiff(pdDiff, NULL);//warm_starter_);
00090     delete diff;
00091 
00092     return retval;
00093   }
00094 
00095 
00096   void
00097   IpoptWarmStart::applyDiff (const CoinWarmStartDiff *const cwsdDiff)
00098   {
00099     IpoptWarmStartDiff const * const ipoptDiff =
00100       dynamic_cast<IpoptWarmStartDiff const * const > (cwsdDiff);
00101     DBG_ASSERT(ipoptDiff);
00102     CoinWarmStartPrimalDual::applyDiff(ipoptDiff);
00103     warm_starter_ = ipoptDiff->warm_starter();
00104   }
00105 
00106   IpoptWarmStart::~IpoptWarmStart()
00107   {}
00108 
00109   void
00110   IpoptWarmStart::flushPoint()
00111   {
00112     CoinWarmStartPrimalDual::clear();
00113   }
00114 
00115   void
00116   IpoptWarmStartDiff::flushPoint()
00117   {
00118     CoinWarmStartPrimalDualDiff::clear();
00119   }
00120 }

Generated on Thu Nov 10 03:05:42 2011 by  doxygen 1.4.7