# HG changeset patch # User alpar # Date 1122930968 0 # Node ID 893dacc1866cf66d3299244c88c6963d3a805f30 # Parent f83d5d39469af22443b69de04e9b1588e3680b6b A default LP solver is defined in lp.h diff -r f83d5d39469a -r 893dacc1866c demo/lp_demo.cc --- a/demo/lp_demo.cc Mon Aug 01 20:20:43 2005 +0000 +++ b/demo/lp_demo.cc Mon Aug 01 21:16:08 2005 +0000 @@ -24,40 +24,21 @@ /// example). For the detailed documentation of the LEMON LP solver /// interface read \ref lemon::LpSolverBase "this". -#ifdef HAVE_CONFIG_H -#include -#endif +#include #include - -#ifdef HAVE_GLPK -#include -#elif HAVE_CPLEX -#include -#endif - using namespace lemon; - - -#ifdef HAVE_GLPK -typedef LpGlpk LpDefault; -const char default_solver_name[]="GLPK"; -#elif HAVE_CPLEX -typedef LpCplex LpDefault; -const char default_solver_name[]="CPLEX"; -#endif - int main() { //The following example is taken from the documentation of the GLPK library. //See it in the GLPK reference manual and among the GLPK sample files (sample.c) //A default solver is taken - LpDefault lp; - typedef LpDefault::Row Row; - typedef LpDefault::Col Col; + Lp lp; + typedef Lp::Row Row; + typedef Lp::Col Col; std::cout<<"A program demonstrating the LEMON LP solver interface"< -#endif - #include #include +#include #include #include -#ifdef HAVE_GLPK -#include -#elif HAVE_CPLEX -#include -#endif using namespace lemon; -#ifdef HAVE_GLPK -typedef LpGlpk LpDefault; -const char default_solver_name[]="GLPK"; -#elif HAVE_CPLEX -typedef LpCplex LpDefault; -const char default_solver_name[]="CPLEX"; -#endif - - template double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t) { - LpDefault lp; + Lp lp; typedef G Graph; typedef typename G::Node Node; @@ -65,7 +48,7 @@ typedef typename G::InEdgeIt InEdgeIt; //Define a map on the edges for the variables of the LP problem - typename G::template EdgeMap x(g); + typename G::template EdgeMap x(g); lp.addColSet(x); //Nonnegativity and capacity constraints @@ -77,14 +60,14 @@ //Flow conservation constraints for the nodes (except for 's' and 't') for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) { - LpDefault::Expr ex; + Lp::Expr ex; for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e]; for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e]; lp.addRow(ex==0); } //Objective function: the flow value entering 't' - LpDefault::Expr obj; + Lp::Expr obj; for(InEdgeIt e(g,t);e!=INVALID;++e) obj+=x[e]; for(OutEdgeIt e(g,t);e!=INVALID;++e) obj-=x[e]; lp.setObj(obj); @@ -93,7 +76,7 @@ //Maximization lp.max(); -#ifdef HAVE_GLPK +#if DEFAULT_LP==GLPK lp.presolver(true); lp.messageLevel(3); #endif diff -r f83d5d39469a -r 893dacc1866c lemon/lp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lemon/lp.h Mon Aug 01 21:16:08 2005 +0000 @@ -0,0 +1,71 @@ +/* -*- C++ -*- + * lemon/lp.h - Part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +#ifndef LEMON_LP_H +#define LEMON_LP_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_GLPK +#include +#elif HAVE_CPLEX +#include +#endif + +///\file +///\brief Defines a default LP solver +///\ingroup gen_opt_group +namespace lemon { + +#ifdef DOXYGEN + ///The default LP solver identifier + + ///The default LP solver identifier. + ///\ingroup gen_opt_group + /// + ///Currently, the possible values are \c GLPK or \c CPLEX +#define DEFAULT_LP SOLVER + ///The default LP solver + + ///The default LP solver. + ///\ingroup gen_opt_group + /// + ///Currently, it is either \c LpGlpk or \c LpCplex + typedef LpGlpk Lp; + ///The default LP solver identifier string + + ///The default LP solver identifier string. + ///\ingroup gen_opt_group + /// + ///Currently, the possible values are "GLPK" or "CPLEX" + const char default_solver_name[]="SOLVER"; +#else +#ifdef HAVE_GLPK +#define DEFAULT_LP GLPK + typedef LpGlpk Lp; + const char default_solver_name[]="GLPK"; +#elif HAVE_CPLEX +#define DEFAULT_LP CPLEX + typedef LpCplex Lp; + const char default_solver_name[]="CPLEX"; +#endif +#endif + +} //namespace lemon + +#endif //LEMON_LP_BASE_H diff -r f83d5d39469a -r 893dacc1866c lemon/lp_base.h --- a/lemon/lp_base.h Mon Aug 01 20:20:43 2005 +0000 +++ b/lemon/lp_base.h Mon Aug 01 21:16:08 2005 +0000 @@ -26,8 +26,6 @@ #include #include -//#include"lin_expr.h" - ///\file ///\brief The interface of the LP solver interface. ///\ingroup gen_opt_group