COIN-OR::LEMON - Graph Library

Ignore:
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • lemon/clp.cc

    r587 r485  
    5757  }
    5858
    59   ClpLp* ClpLp::newSolver() const {
     59  ClpLp* ClpLp::_newSolver() const {
    6060    ClpLp* newlp = new ClpLp;
    6161    return newlp;
    6262  }
    6363
    64   ClpLp* ClpLp::cloneSolver() const {
     64  ClpLp* ClpLp::_cloneSolver() const {
    6565    ClpLp* copylp = new ClpLp(*this);
    6666    return copylp;
  • lemon/clp.h

    r587 r485  
    5757    ~ClpLp();
    5858
    59     /// \e
    60     virtual ClpLp* newSolver() const;
    61     /// \e
    62     virtual ClpLp* cloneSolver() const;
    63 
    6459  protected:
    6560
     
    7166
    7267  protected:
     68
     69    virtual ClpLp* _newSolver() const;
     70    virtual ClpLp* _cloneSolver() const;
    7371
    7472    virtual const char* _solverName() const;
  • lemon/cplex.cc

    r587 r485  
    452452  CplexLp::~CplexLp() {}
    453453
    454   CplexLp* CplexLp::newSolver() const { return new CplexLp; }
    455   CplexLp* CplexLp::cloneSolver() const {return new CplexLp(*this); }
     454  CplexLp* CplexLp::_newSolver() const { return new CplexLp; }
     455  CplexLp* CplexLp::_cloneSolver() const {return new CplexLp(*this); }
    456456
    457457  const char* CplexLp::_solverName() const { return "CplexLp"; }
     
    824824  CplexMip::~CplexMip() {}
    825825
    826   CplexMip* CplexMip::newSolver() const { return new CplexMip; }
    827   CplexMip* CplexMip::cloneSolver() const {return new CplexMip(*this); }
     826  CplexMip* CplexMip::_newSolver() const { return new CplexMip; }
     827  CplexMip* CplexMip::_cloneSolver() const {return new CplexMip(*this); }
    828828
    829829  const char* CplexMip::_solverName() const { return "CplexMip"; }
  • lemon/cplex.h

    r587 r485  
    161161  /// This class implements an interface for the CPLEX LP solver.
    162162  ///\ingroup lp_group
    163   class CplexLp : public LpSolver, public CplexBase {
     163  class CplexLp : public CplexBase, public LpSolver {
    164164  public:
    165165    /// \e
     
    171171    /// \e
    172172    virtual ~CplexLp();
    173 
    174     /// \e
    175     virtual CplexLp* cloneSolver() const;
    176     /// \e
    177     virtual CplexLp* newSolver() const;
    178173
    179174  private:
     
    191186
    192187  protected:
     188
     189    virtual CplexLp* _cloneSolver() const;
     190    virtual CplexLp* _newSolver() const;
    193191
    194192    virtual const char* _solverName() const;
     
    225223  /// This class implements an interface for the CPLEX MIP solver.
    226224  ///\ingroup lp_group
    227   class CplexMip : public MipSolver, public CplexBase {
     225  class CplexMip : public CplexBase, public MipSolver {
    228226  public:
    229227    /// \e
  • lemon/glpk.cc

    r589 r485  
    523523  }
    524524
    525   void GlpkBase::freeEnv() {
    526     glp_free_env();
    527   }
    528 
    529   GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
    530 
    531525  // GlpkLp members
    532526
     
    541535  }
    542536
    543   GlpkLp* GlpkLp::newSolver() const { return new GlpkLp; }
    544   GlpkLp* GlpkLp::cloneSolver() const { return new GlpkLp(*this); }
     537  GlpkLp* GlpkLp::_newSolver() const { return new GlpkLp; }
     538  GlpkLp* GlpkLp::_cloneSolver() const { return new GlpkLp(*this); }
    545539
    546540  const char* GlpkLp::_solverName() const { return "GlpkLp"; }
     
    947941  }
    948942
    949   GlpkMip* GlpkMip::newSolver() const { return new GlpkMip; }
    950   GlpkMip* GlpkMip::cloneSolver() const {return new GlpkMip(*this); }
     943  GlpkMip* GlpkMip::_newSolver() const { return new GlpkMip; }
     944  GlpkMip* GlpkMip::_cloneSolver() const {return new GlpkMip(*this); }
    951945
    952946  const char* GlpkMip::_solverName() const { return "GlpkMip"; }
  • lemon/glpk.h

    r589 r485  
    101101    virtual void _clear();
    102102
    103   private:
    104 
    105     static void freeEnv();
    106 
    107     struct FreeEnvHelper {
    108       ~FreeEnvHelper() {
    109         freeEnv();
    110       }
    111     };
    112    
    113     static FreeEnvHelper freeEnvHelper;
    114    
    115103  public:
    116104
     
    132120  /// This class implements an interface for the GLPK LP solver.
    133121  ///\ingroup lp_group
    134   class GlpkLp : public LpSolver, public GlpkBase {
     122  class GlpkLp : public GlpkBase, public LpSolver {
    135123  public:
    136124
     
    139127    ///\e
    140128    GlpkLp(const GlpkLp&);
    141 
    142     ///\e
    143     virtual GlpkLp* cloneSolver() const;
    144     ///\e
    145     virtual GlpkLp* newSolver() const;
    146129
    147130  private:
     
    153136
    154137  protected:
     138
     139    virtual GlpkLp* _cloneSolver() const;
     140    virtual GlpkLp* _newSolver() const;
    155141
    156142    virtual const char* _solverName() const;
     
    168154    virtual Value _getDualRay(int i) const;
    169155
     156    ///\todo It should be clarified
     157    ///
    170158    virtual ProblemType _getPrimalType() const;
    171159    virtual ProblemType _getDualType() const;
     
    216204  /// This class implements an interface for the GLPK MIP solver.
    217205  ///\ingroup lp_group
    218   class GlpkMip : public MipSolver, public GlpkBase {
     206  class GlpkMip : public GlpkBase, public MipSolver {
    219207  public:
    220208
     
    224212    GlpkMip(const GlpkMip&);
    225213
    226     virtual GlpkMip* cloneSolver() const;
    227     virtual GlpkMip* newSolver() const;
    228 
    229   protected:
     214  protected:
     215
     216    virtual GlpkMip* _cloneSolver() const;
     217    virtual GlpkMip* _newSolver() const;
    230218
    231219    virtual const char* _solverName() const;
  • lemon/lp_base.h

    r587 r561  
    919919
    920920    //Abstract virtual functions
     921    virtual LpBase* _newSolver() const = 0;
     922    virtual LpBase* _cloneSolver() const = 0;
    921923
    922924    virtual int _addColId(int col) { return cols.addIndex(col); }
     
    985987    /// Virtual destructor
    986988    virtual ~LpBase() {}
     989
     990    ///Creates a new LP problem
     991    LpBase* newSolver() {return _newSolver();}
     992    ///Makes a copy of the LP problem
     993    LpBase* cloneSolver() {return _cloneSolver();}
    987994
    988995    ///Gives back the name of the solver.
     
    18151822  public:
    18161823
    1817     ///Allocate a new LP problem instance
    1818     virtual LpSolver* newSolver() const = 0;
    1819     ///Make a copy of the LP problem
    1820     virtual LpSolver* cloneSolver() const = 0;
    1821 
    18221824    ///\name Solve the LP
    18231825
     
    19341936    ///@}
    19351937
     1938    LpSolver* newSolver() {return _newSolver();}
     1939    LpSolver* cloneSolver() {return _cloneSolver();}
     1940
    19361941  protected:
    19371942
     1943    virtual LpSolver* _newSolver() const = 0;
     1944    virtual LpSolver* _cloneSolver() const = 0;
    19381945  };
    19391946
     
    19691976    };
    19701977
    1971     ///Allocate a new MIP problem instance
    1972     virtual MipSolver* newSolver() const = 0;
    1973     ///Make a copy of the MIP problem
    1974     virtual MipSolver* cloneSolver() const = 0;
    1975 
    19761978    ///\name Solve the MIP
    19771979
     
    20612063    virtual Value _getSolValue() const = 0;
    20622064
     2065  public:
     2066
     2067    MipSolver* newSolver() {return _newSolver();}
     2068    MipSolver* cloneSolver() {return _cloneSolver();}
     2069
     2070  protected:
     2071
     2072    virtual MipSolver* _newSolver() const = 0;
     2073    virtual MipSolver* _cloneSolver() const = 0;
    20632074  };
    20642075
  • lemon/lp_skeleton.cc

    r587 r482  
    106106  { return BASIC; }
    107107
    108   LpSkeleton* LpSkeleton::newSolver() const
     108  LpSkeleton* LpSkeleton::_newSolver() const
    109109  { return static_cast<LpSkeleton*>(0); }
    110110
    111   LpSkeleton* LpSkeleton::cloneSolver() const
     111  LpSkeleton* LpSkeleton::_cloneSolver() const
    112112  { return static_cast<LpSkeleton*>(0); }
    113113
     
    123123  { return UNDEFINED; }
    124124
    125   MipSkeleton* MipSkeleton::newSolver() const
     125  MipSkeleton* MipSkeleton::_newSolver() const
    126126  { return static_cast<MipSkeleton*>(0); }
    127127
    128   MipSkeleton* MipSkeleton::cloneSolver() const
     128  MipSkeleton* MipSkeleton::_cloneSolver() const
    129129  { return static_cast<MipSkeleton*>(0); }
    130130
  • lemon/lp_skeleton.h

    r588 r576  
    2323
    2424///\file
    25 ///\brief Skeleton file to implement LP/MIP solver interfaces
    26 /// 
    27 ///The classes in this file do nothing, but they can serve as skeletons when
    28 ///implementing an interface to new solvers.
     25///\brief A skeleton file to implement LP solver interfaces
    2926namespace lemon {
    3027
    31   ///A skeleton class to implement LP/MIP solver base interface
    32  
    33   ///This class does nothing, but it can serve as a skeleton when
    34   ///implementing an interface to new solvers.
     28  ///A skeleton class to implement LP solver interfaces
    3529  class SkeletonSolverBase : public virtual LpBase {
    3630    int col_num,row_num;
     
    143137  };
    144138
    145   /// \brief Skeleton class for an LP solver interface
     139  /// \brief Interface for a skeleton LP solver
    146140  ///
    147   ///This class does nothing, but it can serve as a skeleton when
    148   ///implementing an interface to new solvers.
    149 
     141  /// This class implements an interface for a skeleton LP solver.
    150142  ///\ingroup lp_group
    151   class LpSkeleton : public LpSolver, public SkeletonSolverBase {
     143  class LpSkeleton : public SkeletonSolverBase, public LpSolver {
    152144  public:
    153     ///\e
    154     LpSkeleton() : LpSolver(), SkeletonSolverBase() {}
    155     ///\e
    156     virtual LpSkeleton* newSolver() const;
    157     ///\e
    158     virtual LpSkeleton* cloneSolver() const;
     145    LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
     146
    159147  protected:
    160148
     
    186174
    187175    ///\e
     176    virtual LpSkeleton* _newSolver() const;
     177    ///\e
     178    virtual LpSkeleton* _cloneSolver() const;
     179    ///\e
    188180    virtual const char* _solverName() const;
    189181
    190182  };
    191183
    192   /// \brief Skeleton class for a MIP solver interface
     184  /// \brief Interface for a skeleton MIP solver
    193185  ///
    194   ///This class does nothing, but it can serve as a skeleton when
    195   ///implementing an interface to new solvers.
     186  /// This class implements an interface for a skeleton MIP solver.
    196187  ///\ingroup lp_group
    197   class MipSkeleton : public MipSolver, public SkeletonSolverBase {
     188  class MipSkeleton : public SkeletonSolverBase, public MipSolver {
    198189  public:
    199     ///\e
    200     MipSkeleton() : MipSolver(), SkeletonSolverBase() {}
    201     ///\e
    202     virtual MipSkeleton* newSolver() const;
    203     ///\e
    204     virtual MipSkeleton* cloneSolver() const;
     190    MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
    205191
    206192  protected:
    207193    ///\e
     194
     195    ///\bug Wrong interface
     196    ///
    208197    virtual SolveExitStatus _solve();
    209198
    210199    ///\e
     200
     201    ///\bug Wrong interface
     202    ///
    211203    virtual Value _getSol(int i) const;
    212204
    213205    ///\e
     206
     207    ///\bug Wrong interface
     208    ///
    214209    virtual Value _getSolValue() const;
    215210
    216211    ///\e
     212
     213    ///\bug Wrong interface
     214    ///
    217215    virtual ProblemType _getType() const;
    218216
    219217    ///\e
     218    virtual MipSkeleton* _newSolver() const;
     219
     220    ///\e
     221    virtual MipSkeleton* _cloneSolver() const;
     222    ///\e
    220223    virtual const char* _solverName() const;
     224
    221225  };
    222226
  • lemon/soplex.cc

    r587 r485  
    2020#include <lemon/soplex.h>
    2121
    22 #include <soplex.h>
     22#include <soplex/soplex.h>
    2323
    2424
     
    5555  }
    5656
    57   SoplexLp* SoplexLp::newSolver() const {
     57  SoplexLp* SoplexLp::_newSolver() const {
    5858    SoplexLp* newlp = new SoplexLp();
    5959    return newlp;
    6060  }
    6161
    62   SoplexLp* SoplexLp::cloneSolver() const {
     62  SoplexLp* SoplexLp::_cloneSolver() const {
    6363    SoplexLp* newlp = new SoplexLp(*this);
    6464    return newlp;
  • lemon/soplex.h

    r587 r485  
    7474    /// \e
    7575    ~SoplexLp();
    76     /// \e
    77     virtual SoplexLp* newSolver() const;
    78     /// \e
    79     virtual SoplexLp* cloneSolver() const;
    8076
    8177  protected:
     78
     79    virtual SoplexLp* _newSolver() const;
     80    virtual SoplexLp* _cloneSolver() const;
    8281
    8382    virtual const char* _solverName() const;
  • m4/lx_check_soplex.m4

    r586 r480  
    2121      SOPLEX_CXXFLAGS="-I$with_soplex_includedir"
    2222    elif test x"$with_soplex" != x"yes"; then
    23       SOPLEX_CXXFLAGS="-I$with_soplex/src"
     23      SOPLEX_CXXFLAGS="-I$with_soplex/include"
    2424    fi
    2525
     
    3939
    4040    lx_soplex_test_prog='
    41       #include <soplex.h>
     41      #include <soplex/soplex.h>
    4242
    4343      int main(int argc, char** argv)
  • test/lp_test.cc

    r589 r485  
    198198    check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str());
    199199
    200     //Test for clone/new
    201     LP* lpnew = lp.newSolver();
    202     LP* lpclone = lp.cloneSolver();
    203     delete lpnew;
    204     delete lpclone;
    205200
    206201  }
     
    253248  if (stat ==  LpSolver::OPTIMAL) {
    254249    std::ostringstream sbuf;
    255     sbuf << "Wrong optimal value (" << lp.primal() <<") with "
    256          << lp.solverName() <<"\n     the right optimum is " << exp_opt;
     250    sbuf << "Wrong optimal value: the right optimum is " << exp_opt;
    257251    check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str());
    258252  }
     
    362356}
    363357
    364 template<class LP>
    365 void cloneTest()
    366 {
    367   //Test for clone/new
    368  
    369   LP* lp = new LP();
    370   LP* lpnew = lp->newSolver();
    371   LP* lpclone = lp->cloneSolver();
    372   delete lp;
    373   delete lpnew;
    374   delete lpclone;
    375 }
    376 
    377358int main()
    378359{
     
    385366    lpTest(lp_glpk1);
    386367    aTest(lp_glpk2);
    387     cloneTest<GlpkLp>();
    388368  }
    389369#endif
     
    402382#endif
    403383  }
    404     cloneTest<CplexLp>();
    405384#endif
    406385
     
    410389    lpTest(lp_soplex1);
    411390    aTest(lp_soplex2);
    412     cloneTest<SoplexLp>();
    413391  }
    414392#endif
     
    419397    lpTest(lp_clp1);
    420398    aTest(lp_clp2);
    421     cloneTest<ClpLp>();
    422399  }
    423400#endif
  • test/mip_test.cc

    r589 r485  
    107107}
    108108
    109 template<class MIP>
    110 void cloneTest()
    111 {
    112  
    113   MIP* mip = new MIP();
    114   MIP* mipnew = mip->newSolver();
    115   MIP* mipclone = mip->cloneSolver();
    116   delete mip;
    117   delete mipnew;
    118   delete mipclone;
    119 }
    120109
    121110int main()
     
    126115    GlpkMip mip1;
    127116    aTest(mip1);
    128     cloneTest<GlpkMip>();
    129117  }
    130118#endif
     
    142130#endif
    143131  }
    144   cloneTest<CplexMip>();
    145132#endif
    146133
Note: See TracChangeset for help on using the changeset viewer.