/home/coin/SVN-release/OS-1.1.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 
00018 namespace Bonmin
00019 {
00021   IpoptWarmStart::IpoptWarmStart
00022   (bool empty, int numvars, int numcont):
00023       CoinWarmStartPrimalDual(),
00024       CoinWarmStartBasis(),
00025       warm_starter_(NULL),
00026       empty_(empty)
00027   {
00028     setSize(numvars,numcont);
00029   }
00031   IpoptWarmStart::IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
00032       SmartPtr<IpoptInteriorWarmStarter> warm_starter):
00033       CoinWarmStartPrimalDual(tnlp->num_variables(),
00034                               2*tnlp->num_variables()+tnlp->num_constraints(),
00035                               tnlp->x_sol(), tnlp->duals_sol() ),
00036       CoinWarmStartBasis(),
00037       warm_starter_(warm_starter),
00038       empty_(false)
00039   {
00040     int numcols = tnlp->num_variables();
00041     int numrows = tnlp->num_constraints();
00042     // initialize the size in the CoinWarmStartBasis part
00043     setSize(numcols,numrows);
00044   }
00045 
00047 IpoptWarmStart::IpoptWarmStart(int primal_size, int dual_size,
00048                    const double * primal, const double * dual):
00049           CoinWarmStartPrimalDual(primal_size, dual_size, primal, dual),
00050           CoinWarmStartBasis(),
00051           warm_starter_(NULL), 
00052           empty_(false)
00053 {
00054    setSize(primal_size, dual_size - 2* primal_size);
00055 }
00057   IpoptWarmStart::IpoptWarmStart( const IpoptWarmStart &other, bool ownValues):
00058     CoinWarmStartPrimalDual(other),
00059     CoinWarmStartBasis(other),
00060     warm_starter_(NULL /*other.warm_starter_*/),
00061     empty_(other.empty_)
00062   {
00063     //  if(ownValues_ && other.values_ != NULL)
00064   }
00065 
00067   IpoptWarmStart::IpoptWarmStart(const CoinWarmStartPrimalDual& pdws) :
00068     CoinWarmStartPrimalDual(pdws),
00069     CoinWarmStartBasis(),
00070     warm_starter_(NULL),
00071     empty_(false)
00072   {   
00073   }
00074   
00075   CoinWarmStartDiff*
00076   IpoptWarmStart::generateDiff(const CoinWarmStart *const oldCWS) const
00077   {
00078     const IpoptWarmStart * const ws =
00079       dynamic_cast< const IpoptWarmStart * const > (oldCWS);
00080     DBG_ASSERT(ws);
00081 
00082     CoinWarmStartDiff * diff = CoinWarmStartPrimalDual::generateDiff(ws);
00083 
00084     CoinWarmStartPrimalDualDiff * pdDiff =
00085       dynamic_cast<CoinWarmStartPrimalDualDiff*>(diff);
00086 
00087     CoinWarmStartDiff* retval =
00088       new IpoptWarmStartDiff(pdDiff, NULL);//warm_starter_);
00089     delete diff;
00090 
00091     return retval;
00092   }
00093 
00094 
00095   void
00096   IpoptWarmStart::applyDiff (const CoinWarmStartDiff *const cwsdDiff)
00097   {
00098     IpoptWarmStartDiff const * const ipoptDiff =
00099       dynamic_cast<IpoptWarmStartDiff const * const > (cwsdDiff);
00100     DBG_ASSERT(ipoptDiff);
00101     CoinWarmStartPrimalDual::applyDiff(ipoptDiff);
00102     warm_starter_ = ipoptDiff->warm_starter();
00103   }
00104 
00105   IpoptWarmStart::~IpoptWarmStart()
00106   {}
00107 
00108   void
00109   IpoptWarmStart::flushPoint()
00110   {
00111     CoinWarmStartPrimalDual::clear();
00112   }
00113 
00114   void
00115   IpoptWarmStartDiff::flushPoint()
00116   {
00117     CoinWarmStartPrimalDualDiff::clear();
00118   }
00119 }

Generated on Tue Sep 30 03:01:24 2008 by  doxygen 1.4.7