1.1 --- a/test/lp_test.cc Mon Jan 12 23:11:39 2009 +0100
1.2 +++ b/test/lp_test.cc Thu Nov 05 15:48:01 2009 +0100
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2008
1.8 + * Copyright (C) 2003-2009
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -21,23 +21,21 @@
1.13 #include "test_tools.h"
1.14 #include <lemon/tolerance.h>
1.15
1.16 -#ifdef HAVE_CONFIG_H
1.17 #include <lemon/config.h>
1.18 -#endif
1.19
1.20 -#ifdef HAVE_GLPK
1.21 +#ifdef LEMON_HAVE_GLPK
1.22 #include <lemon/glpk.h>
1.23 #endif
1.24
1.25 -#ifdef HAVE_CPLEX
1.26 +#ifdef LEMON_HAVE_CPLEX
1.27 #include <lemon/cplex.h>
1.28 #endif
1.29
1.30 -#ifdef HAVE_SOPLEX
1.31 +#ifdef LEMON_HAVE_SOPLEX
1.32 #include <lemon/soplex.h>
1.33 #endif
1.34
1.35 -#ifdef HAVE_CLP
1.36 +#ifdef LEMON_HAVE_CLP
1.37 #include <lemon/clp.h>
1.38 #endif
1.39
1.40 @@ -197,6 +195,11 @@
1.41 buf << "Coeff. of p2 should be 0";
1.42 check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str());
1.43
1.44 + //Test for clone/new
1.45 + LP* lpnew = lp.newSolver();
1.46 + LP* lpclone = lp.cloneSolver();
1.47 + delete lpnew;
1.48 + delete lpclone;
1.49
1.50 }
1.51
1.52 @@ -247,7 +250,8 @@
1.53
1.54 if (stat == LpSolver::OPTIMAL) {
1.55 std::ostringstream sbuf;
1.56 - sbuf << "Wrong optimal value: the right optimum is " << exp_opt;
1.57 + sbuf << "Wrong optimal value (" << lp.primal() <<") with "
1.58 + << lp.solverName() <<"\n the right optimum is " << exp_opt;
1.59 check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str());
1.60 }
1.61 }
1.62 @@ -355,47 +359,59 @@
1.63
1.64 }
1.65
1.66 +template<class LP>
1.67 +void cloneTest()
1.68 +{
1.69 + //Test for clone/new
1.70 +
1.71 + LP* lp = new LP();
1.72 + LP* lpnew = lp->newSolver();
1.73 + LP* lpclone = lp->cloneSolver();
1.74 + delete lp;
1.75 + delete lpnew;
1.76 + delete lpclone;
1.77 +}
1.78 +
1.79 int main()
1.80 {
1.81 LpSkeleton lp_skel;
1.82 lpTest(lp_skel);
1.83
1.84 -#ifdef HAVE_GLPK
1.85 +#ifdef LEMON_HAVE_GLPK
1.86 {
1.87 GlpkLp lp_glpk1,lp_glpk2;
1.88 lpTest(lp_glpk1);
1.89 aTest(lp_glpk2);
1.90 + cloneTest<GlpkLp>();
1.91 }
1.92 #endif
1.93
1.94 -#ifdef HAVE_CPLEX
1.95 +#ifdef LEMON_HAVE_CPLEX
1.96 try {
1.97 CplexLp lp_cplex1,lp_cplex2;
1.98 lpTest(lp_cplex1);
1.99 aTest(lp_cplex2);
1.100 + cloneTest<CplexLp>();
1.101 } catch (CplexEnv::LicenseError& error) {
1.102 -#ifdef LEMON_FORCE_CPLEX_CHECK
1.103 check(false, error.what());
1.104 -#else
1.105 - std::cerr << error.what() << std::endl;
1.106 - std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
1.107 -#endif
1.108 }
1.109 #endif
1.110
1.111 -#ifdef HAVE_SOPLEX
1.112 +#ifdef LEMON_HAVE_SOPLEX
1.113 {
1.114 SoplexLp lp_soplex1,lp_soplex2;
1.115 lpTest(lp_soplex1);
1.116 aTest(lp_soplex2);
1.117 + cloneTest<SoplexLp>();
1.118 }
1.119 #endif
1.120
1.121 -#ifdef HAVE_CLP
1.122 +#ifdef LEMON_HAVE_CLP
1.123 {
1.124 ClpLp lp_clp1,lp_clp2;
1.125 lpTest(lp_clp1);
1.126 aTest(lp_clp2);
1.127 + cloneTest<ClpLp>();
1.128 }
1.129 #endif
1.130