1.1 --- a/demo/lp_demo.cc Mon Aug 01 20:20:43 2005 +0000
1.2 +++ b/demo/lp_demo.cc Mon Aug 01 21:16:08 2005 +0000
1.3 @@ -24,40 +24,21 @@
1.4 /// example). For the detailed documentation of the LEMON LP solver
1.5 /// interface read \ref lemon::LpSolverBase "this".
1.6
1.7 -#ifdef HAVE_CONFIG_H
1.8 -#include <config.h>
1.9 -#endif
1.10 +#include <lemon/lp.h>
1.11
1.12 #include <iostream>
1.13
1.14 -
1.15 -#ifdef HAVE_GLPK
1.16 -#include <lemon/lp_glpk.h>
1.17 -#elif HAVE_CPLEX
1.18 -#include <lemon/lp_cplex.h>
1.19 -#endif
1.20 -
1.21 using namespace lemon;
1.22
1.23 -
1.24 -
1.25 -#ifdef HAVE_GLPK
1.26 -typedef LpGlpk LpDefault;
1.27 -const char default_solver_name[]="GLPK";
1.28 -#elif HAVE_CPLEX
1.29 -typedef LpCplex LpDefault;
1.30 -const char default_solver_name[]="CPLEX";
1.31 -#endif
1.32 -
1.33 int main()
1.34 {
1.35 //The following example is taken from the documentation of the GLPK library.
1.36 //See it in the GLPK reference manual and among the GLPK sample files (sample.c)
1.37
1.38 //A default solver is taken
1.39 - LpDefault lp;
1.40 - typedef LpDefault::Row Row;
1.41 - typedef LpDefault::Col Col;
1.42 + Lp lp;
1.43 + typedef Lp::Row Row;
1.44 + typedef Lp::Col Col;
1.45
1.46
1.47 std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl;
2.1 --- a/demo/lp_maxflow_demo.cc Mon Aug 01 20:20:43 2005 +0000
2.2 +++ b/demo/lp_maxflow_demo.cc Mon Aug 01 21:16:08 2005 +0000
2.3 @@ -23,38 +23,21 @@
2.4 /// the emphasis on the simplicity of the way one can formulate LP
2.5 /// constraints that arise in graph theory in our library LEMON .
2.6
2.7 -#ifdef HAVE_CONFIG_H
2.8 -#include <config.h>
2.9 -#endif
2.10 -
2.11 #include<lemon/graph_reader.h>
2.12 #include<lemon/list_graph.h>
2.13 +#include <lemon/lp.h>
2.14
2.15 #include <fstream>
2.16 #include <iostream>
2.17
2.18
2.19 -#ifdef HAVE_GLPK
2.20 -#include <lemon/lp_glpk.h>
2.21 -#elif HAVE_CPLEX
2.22 -#include <lemon/lp_cplex.h>
2.23 -#endif
2.24
2.25 using namespace lemon;
2.26
2.27 -#ifdef HAVE_GLPK
2.28 -typedef LpGlpk LpDefault;
2.29 -const char default_solver_name[]="GLPK";
2.30 -#elif HAVE_CPLEX
2.31 -typedef LpCplex LpDefault;
2.32 -const char default_solver_name[]="CPLEX";
2.33 -#endif
2.34 -
2.35 -
2.36 template<class G,class C>
2.37 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
2.38 {
2.39 - LpDefault lp;
2.40 + Lp lp;
2.41
2.42 typedef G Graph;
2.43 typedef typename G::Node Node;
2.44 @@ -65,7 +48,7 @@
2.45 typedef typename G::InEdgeIt InEdgeIt;
2.46
2.47 //Define a map on the edges for the variables of the LP problem
2.48 - typename G::template EdgeMap<LpDefault::Col> x(g);
2.49 + typename G::template EdgeMap<Lp::Col> x(g);
2.50 lp.addColSet(x);
2.51
2.52 //Nonnegativity and capacity constraints
2.53 @@ -77,14 +60,14 @@
2.54
2.55 //Flow conservation constraints for the nodes (except for 's' and 't')
2.56 for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
2.57 - LpDefault::Expr ex;
2.58 + Lp::Expr ex;
2.59 for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e];
2.60 for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
2.61 lp.addRow(ex==0);
2.62 }
2.63
2.64 //Objective function: the flow value entering 't'
2.65 - LpDefault::Expr obj;
2.66 + Lp::Expr obj;
2.67 for(InEdgeIt e(g,t);e!=INVALID;++e) obj+=x[e];
2.68 for(OutEdgeIt e(g,t);e!=INVALID;++e) obj-=x[e];
2.69 lp.setObj(obj);
2.70 @@ -93,7 +76,7 @@
2.71 //Maximization
2.72 lp.max();
2.73
2.74 -#ifdef HAVE_GLPK
2.75 +#if DEFAULT_LP==GLPK
2.76 lp.presolver(true);
2.77 lp.messageLevel(3);
2.78 #endif
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/lemon/lp.h Mon Aug 01 21:16:08 2005 +0000
3.3 @@ -0,0 +1,71 @@
3.4 +/* -*- C++ -*-
3.5 + * lemon/lp.h - Part of LEMON, a generic C++ optimization library
3.6 + *
3.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
3.9 + *
3.10 + * Permission to use, modify and distribute this software is granted
3.11 + * provided that this copyright notice appears in all copies. For
3.12 + * precise terms see the accompanying LICENSE file.
3.13 + *
3.14 + * This software is provided "AS IS" with no warranty of any kind,
3.15 + * express or implied, and with no claim as to its suitability for any
3.16 + * purpose.
3.17 + *
3.18 + */
3.19 +
3.20 +#ifndef LEMON_LP_H
3.21 +#define LEMON_LP_H
3.22 +
3.23 +#ifdef HAVE_CONFIG_H
3.24 +#include<lemon/config.h>
3.25 +#endif
3.26 +
3.27 +#ifdef HAVE_GLPK
3.28 +#include <lemon/lp_glpk.h>
3.29 +#elif HAVE_CPLEX
3.30 +#include <lemon/lp_cplex.h>
3.31 +#endif
3.32 +
3.33 +///\file
3.34 +///\brief Defines a default LP solver
3.35 +///\ingroup gen_opt_group
3.36 +namespace lemon {
3.37 +
3.38 +#ifdef DOXYGEN
3.39 + ///The default LP solver identifier
3.40 +
3.41 + ///The default LP solver identifier.
3.42 + ///\ingroup gen_opt_group
3.43 + ///
3.44 + ///Currently, the possible values are \c GLPK or \c CPLEX
3.45 +#define DEFAULT_LP SOLVER
3.46 + ///The default LP solver
3.47 +
3.48 + ///The default LP solver.
3.49 + ///\ingroup gen_opt_group
3.50 + ///
3.51 + ///Currently, it is either \c LpGlpk or \c LpCplex
3.52 + typedef LpGlpk Lp;
3.53 + ///The default LP solver identifier string
3.54 +
3.55 + ///The default LP solver identifier string.
3.56 + ///\ingroup gen_opt_group
3.57 + ///
3.58 + ///Currently, the possible values are "GLPK" or "CPLEX"
3.59 + const char default_solver_name[]="SOLVER";
3.60 +#else
3.61 +#ifdef HAVE_GLPK
3.62 +#define DEFAULT_LP GLPK
3.63 + typedef LpGlpk Lp;
3.64 + const char default_solver_name[]="GLPK";
3.65 +#elif HAVE_CPLEX
3.66 +#define DEFAULT_LP CPLEX
3.67 + typedef LpCplex Lp;
3.68 + const char default_solver_name[]="CPLEX";
3.69 +#endif
3.70 +#endif
3.71 +
3.72 +} //namespace lemon
3.73 +
3.74 +#endif //LEMON_LP_BASE_H
4.1 --- a/lemon/lp_base.h Mon Aug 01 20:20:43 2005 +0000
4.2 +++ b/lemon/lp_base.h Mon Aug 01 21:16:08 2005 +0000
4.3 @@ -26,8 +26,6 @@
4.4 #include<lemon/error.h>
4.5 #include<lemon/invalid.h>
4.6
4.7 -//#include"lin_expr.h"
4.8 -
4.9 ///\file
4.10 ///\brief The interface of the LP solver interface.
4.11 ///\ingroup gen_opt_group