0
3
0
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_LP_BASE_H |
20 | 20 |
#define LEMON_LP_BASE_H |
21 | 21 |
|
22 | 22 |
#include<iostream> |
23 | 23 |
#include<vector> |
24 | 24 |
#include<map> |
25 | 25 |
#include<limits> |
26 | 26 |
#include<lemon/math.h> |
27 | 27 |
|
28 | 28 |
#include<lemon/error.h> |
29 | 29 |
#include<lemon/assert.h> |
30 | 30 |
|
31 | 31 |
#include<lemon/core.h> |
32 | 32 |
#include<lemon/bits/solver_bits.h> |
33 | 33 |
|
34 | 34 |
///\file |
35 | 35 |
///\brief The interface of the LP solver interface. |
36 | 36 |
///\ingroup lp_group |
37 | 37 |
namespace lemon { |
38 | 38 |
|
39 | 39 |
///Common base class for LP and MIP solvers |
40 | 40 |
|
41 | 41 |
///Usually this class is not used directly, please use one of the concrete |
42 | 42 |
///implementations of the solver interface. |
43 | 43 |
///\ingroup lp_group |
44 | 44 |
class LpBase { |
45 | 45 |
|
46 | 46 |
protected: |
47 | 47 |
|
48 | 48 |
_solver_bits::VarIndex rows; |
49 | 49 |
_solver_bits::VarIndex cols; |
50 | 50 |
|
51 | 51 |
public: |
52 | 52 |
|
53 | 53 |
///Possible outcomes of an LP solving procedure |
... | ... |
@@ -72,97 +72,97 @@ |
72 | 72 |
std::istringstream input(test_lgf); |
73 | 73 |
digraphReader(d, input). |
74 | 74 |
node("source", s). |
75 | 75 |
node("target", t). |
76 | 76 |
arcMap("label", label). |
77 | 77 |
run(); |
78 | 78 |
check(countNodes(d) == 2,"There should be 2 nodes"); |
79 | 79 |
check(countArcs(d) == 2,"There should be 2 arcs"); |
80 | 80 |
} |
81 | 81 |
{ |
82 | 82 |
ListGraph g; |
83 | 83 |
ListGraph::Node s,t; |
84 | 84 |
ListGraph::EdgeMap<int> label(g); |
85 | 85 |
std::istringstream input(test_lgf); |
86 | 86 |
graphReader(g, input). |
87 | 87 |
node("source", s). |
88 | 88 |
node("target", t). |
89 | 89 |
edgeMap("label", label). |
90 | 90 |
run(); |
91 | 91 |
check(countNodes(g) == 2,"There should be 2 nodes"); |
92 | 92 |
check(countEdges(g) == 2,"There should be 2 arcs"); |
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
{ |
96 | 96 |
ListDigraph d; |
97 | 97 |
std::istringstream input(test_lgf_nomap); |
98 | 98 |
digraphReader(d, input). |
99 | 99 |
run(); |
100 | 100 |
check(countNodes(d) == 2,"There should be 2 nodes"); |
101 | 101 |
check(countArcs(d) == 1,"There should be 1 arc"); |
102 | 102 |
} |
103 | 103 |
{ |
104 | 104 |
ListGraph g; |
105 | 105 |
std::istringstream input(test_lgf_nomap); |
106 | 106 |
graphReader(g, input). |
107 | 107 |
run(); |
108 | 108 |
check(countNodes(g) == 2,"There should be 2 nodes"); |
109 | 109 |
check(countEdges(g) == 1,"There should be 1 edge"); |
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
{ |
113 | 113 |
ListDigraph d; |
114 | 114 |
std::istringstream input(test_lgf_bad1); |
115 | 115 |
bool ok=false; |
116 | 116 |
try { |
117 | 117 |
digraphReader(d, input). |
118 | 118 |
run(); |
119 | 119 |
} |
120 |
catch (FormatError&) |
|
120 |
catch (FormatError&) |
|
121 | 121 |
{ |
122 | 122 |
ok = true; |
123 | 123 |
} |
124 | 124 |
check(ok,"FormatError exception should have occured"); |
125 | 125 |
} |
126 | 126 |
{ |
127 | 127 |
ListGraph g; |
128 | 128 |
std::istringstream input(test_lgf_bad1); |
129 | 129 |
bool ok=false; |
130 | 130 |
try { |
131 | 131 |
graphReader(g, input). |
132 | 132 |
run(); |
133 | 133 |
} |
134 | 134 |
catch (FormatError&) |
135 | 135 |
{ |
136 | 136 |
ok = true; |
137 | 137 |
} |
138 | 138 |
check(ok,"FormatError exception should have occured"); |
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
{ |
142 | 142 |
ListDigraph d; |
143 | 143 |
std::istringstream input(test_lgf_bad2); |
144 | 144 |
bool ok=false; |
145 | 145 |
try { |
146 | 146 |
digraphReader(d, input). |
147 | 147 |
run(); |
148 | 148 |
} |
149 | 149 |
catch (FormatError&) |
150 | 150 |
{ |
151 | 151 |
ok = true; |
152 | 152 |
} |
153 | 153 |
check(ok,"FormatError exception should have occured"); |
154 | 154 |
} |
155 | 155 |
{ |
156 | 156 |
ListGraph g; |
157 | 157 |
std::istringstream input(test_lgf_bad2); |
158 | 158 |
bool ok=false; |
159 | 159 |
try { |
160 | 160 |
graphReader(g, input). |
161 | 161 |
run(); |
162 | 162 |
} |
163 | 163 |
catch (FormatError&) |
164 | 164 |
{ |
165 | 165 |
ok = true; |
166 | 166 |
} |
167 | 167 |
check(ok,"FormatError exception should have occured"); |
168 | 168 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <sstream> |
20 | 20 |
#include <lemon/lp_skeleton.h> |
21 | 21 |
#include "test_tools.h" |
22 | 22 |
#include <lemon/tolerance.h> |
23 | 23 |
|
24 | 24 |
#include <lemon/config.h> |
25 | 25 |
|
26 | 26 |
#ifdef LEMON_HAVE_GLPK |
27 | 27 |
#include <lemon/glpk.h> |
28 | 28 |
#endif |
29 | 29 |
|
30 | 30 |
#ifdef LEMON_HAVE_CPLEX |
31 | 31 |
#include <lemon/cplex.h> |
32 | 32 |
#endif |
33 | 33 |
|
34 | 34 |
#ifdef LEMON_HAVE_SOPLEX |
35 | 35 |
#include <lemon/soplex.h> |
36 | 36 |
#endif |
37 | 37 |
|
38 | 38 |
#ifdef LEMON_HAVE_CLP |
39 | 39 |
#include <lemon/clp.h> |
40 | 40 |
#endif |
41 | 41 |
|
42 | 42 |
using namespace lemon; |
43 | 43 |
|
44 | 44 |
void lpTest(LpSolver& lp) |
45 | 45 |
{ |
46 | 46 |
|
47 | 47 |
typedef LpSolver LP; |
48 | 48 |
|
49 | 49 |
std::vector<LP::Col> x(10); |
50 | 50 |
// for(int i=0;i<10;i++) x.push_back(lp.addCol()); |
51 | 51 |
lp.addColSet(x); |
52 | 52 |
lp.colLowerBound(x,1); |
53 | 53 |
lp.colUpperBound(x,1); |
0 comments (0 inline)