Location: LEMON/LEMON-main/test/lp_test.cc - annotation

Load file history
gravatar
kpeter (Peter Kovacs)
Use XTI implementation instead of ATI in NetworkSimplex (#234) XTI (eXtended Threaded Index) is an imporved version of the widely known ATI (Augmented Threaded Index) method for storing and updating the spanning tree structure in Network Simplex algorithms. In the ATI data structure three indices are stored for each node: predecessor, thread and depth. In the XTI data structure depth is replaced by the number of successors and the last successor (according to the thread index).
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r461:08d495d48089
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r461:08d495d48089
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r461:08d495d48089
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r461:08d495d48089
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r460:76ec7bd57026
 r460:76ec7bd57026
 r458:7afc121e0689
 r460:76ec7bd57026
 r460:76ec7bd57026
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r460:76ec7bd57026
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r462:9b082b3fb33f
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r462:9b082b3fb33f
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r459:ed54c0d13df0
 r462:9b082b3fb33f
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r462:9b082b3fb33f
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r459:ed54c0d13df0
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
 r458:7afc121e0689
/* -*- mode: C++; indent-tabs-mode: nil; -*-
 *
 * This file is a part of LEMON, a generic C++ optimization library.
 *
 * Copyright (C) 2003-2008
 * 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.
 *
 */

#include <sstream>
#include <lemon/lp_skeleton.h>
#include "test_tools.h"
#include <lemon/tolerance.h>

#ifdef HAVE_CONFIG_H
#include <lemon/config.h>
#endif

#ifdef HAVE_GLPK
#include <lemon/glpk.h>
#endif

#ifdef HAVE_CPLEX
#include <lemon/cplex.h>
#endif

#ifdef HAVE_SOPLEX
#include <lemon/soplex.h>
#endif

#ifdef HAVE_CLP
#include <lemon/clp.h>
#endif

using namespace lemon;

void lpTest(LpSolver& lp)
{

  typedef LpSolver LP;

  std::vector<LP::Col> x(10);
  //  for(int i=0;i<10;i++) x.push_back(lp.addCol());
  lp.addColSet(x);
  lp.colLowerBound(x,1);
  lp.colUpperBound(x,1);
  lp.colBounds(x,1,2);

  std::vector<LP::Col> y(10);
  lp.addColSet(y);

  lp.colLowerBound(y,1);
  lp.colUpperBound(y,1);
  lp.colBounds(y,1,2);

  std::map<int,LP::Col> z;

  z.insert(std::make_pair(12,INVALID));
  z.insert(std::make_pair(2,INVALID));
  z.insert(std::make_pair(7,INVALID));
  z.insert(std::make_pair(5,INVALID));

  lp.addColSet(z);

  lp.colLowerBound(z,1);
  lp.colUpperBound(z,1);
  lp.colBounds(z,1,2);

  {
    LP::Expr e,f,g;
    LP::Col p1,p2,p3,p4,p5;
    LP::Constr c;

    p1=lp.addCol();
    p2=lp.addCol();
    p3=lp.addCol();
    p4=lp.addCol();
    p5=lp.addCol();

    e[p1]=2;
    *e=12;
    e[p1]+=2;
    *e+=12;
    e[p1]-=2;
    *e-=12;

    e=2;
    e=2.2;
    e=p1;
    e=f;

    e+=2;
    e+=2.2;
    e+=p1;
    e+=f;

    e-=2;
    e-=2.2;
    e-=p1;
    e-=f;

    e*=2;
    e*=2.2;
    e/=2;
    e/=2.2;

    e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
       (f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
       (f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
       2.2*f+f*2.2+f/2.2+
       2*f+f*2+f/2+
       2.2*p1+p1*2.2+p1/2.2+
       2*p1+p1*2+p1/2
       );


    c = (e  <= f  );
    c = (e  <= 2.2);
    c = (e  <= 2  );
    c = (e  <= p1 );
    c = (2.2<= f  );
    c = (2  <= f  );
    c = (p1 <= f  );
    c = (p1 <= p2 );
    c = (p1 <= 2.2);
    c = (p1 <= 2  );
    c = (2.2<= p2 );
    c = (2  <= p2 );

    c = (e  >= f  );
    c = (e  >= 2.2);
    c = (e  >= 2  );
    c = (e  >= p1 );
    c = (2.2>= f  );
    c = (2  >= f  );
    c = (p1 >= f  );
    c = (p1 >= p2 );
    c = (p1 >= 2.2);
    c = (p1 >= 2  );
    c = (2.2>= p2 );
    c = (2  >= p2 );

    c = (e  == f  );
    c = (e  == 2.2);
    c = (e  == 2  );
    c = (e  == p1 );
    c = (2.2== f  );
    c = (2  == f  );
    c = (p1 == f  );
    //c = (p1 == p2 );
    c = (p1 == 2.2);
    c = (p1 == 2  );
    c = (2.2== p2 );
    c = (2  == p2 );

    c = ((2 <= e) <= 3);
    c = ((2 <= p1) <= 3);

    c = ((2 >= e) >= 3);
    c = ((2 >= p1) >= 3);

    e[x[3]]=2;
    e[x[3]]=4;
    e[x[3]]=1;
    *e=12;

    lp.addRow(-LP::INF,e,23);
    lp.addRow(-LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
    lp.addRow(-LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);

    lp.addRow(x[1]+x[3]<=x[5]-3);
    lp.addRow((-7<=x[1]+x[3]-12)<=3);
    lp.addRow(x[1]<=x[5]);

    std::ostringstream buf;


    e=((p1+p2)+(p1-0.99*p2));
    //e.prettyPrint(std::cout);
    //(e<=2).prettyPrint(std::cout);
    double tolerance=0.001;
    e.simplify(tolerance);
    buf << "Coeff. of p2 should be 0.01";
    check(e[p2]>0, buf.str());

    tolerance=0.02;
    e.simplify(tolerance);
    buf << "Coeff. of p2 should be 0";
    check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str());


  }

  {
    LP::DualExpr e,f,g;
    LP::Row p1 = INVALID, p2 = INVALID, p3 = INVALID,
      p4 = INVALID, p5 = INVALID;

    e[p1]=2;
    e[p1]+=2;
    e[p1]-=2;

    e=p1;
    e=f;

    e+=p1;
    e+=f;

    e-=p1;
    e-=f;

    e*=2;
    e*=2.2;
    e/=2;
    e/=2.2;

    e=((p1+p2)+(p1-p2)+
       (p1+f)+(f+p1)+(f+g)+
       (p1-f)+(f-p1)+(f-g)+
       2.2*f+f*2.2+f/2.2+
       2*f+f*2+f/2+
       2.2*p1+p1*2.2+p1/2.2+
       2*p1+p1*2+p1/2
       );
  }

}

void solveAndCheck(LpSolver& lp, LpSolver::ProblemType stat,
                   double exp_opt) {
  using std::string;
  lp.solve();

  std::ostringstream buf;
  buf << "PrimalType should be: " << int(stat) << int(lp.primalType());

  check(lp.primalType()==stat, buf.str());

  if (stat ==  LpSolver::OPTIMAL) {
    std::ostringstream sbuf;
    sbuf << "Wrong optimal value: the right optimum is " << exp_opt;
    check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str());
  }
}

void aTest(LpSolver & lp)
{
  typedef LpSolver LP;

 //The following example is very simple

  typedef LpSolver::Row Row;
  typedef LpSolver::Col Col;


  Col x1 = lp.addCol();
  Col x2 = lp.addCol();


  //Constraints
  Row upright=lp.addRow(x1+2*x2 <=1);
  lp.addRow(x1+x2 >=-1);
  lp.addRow(x1-x2 <=1);
  lp.addRow(x1-x2 >=-1);
  //Nonnegativity of the variables
  lp.colLowerBound(x1, 0);
  lp.colLowerBound(x2, 0);
  //Objective function
  lp.obj(x1+x2);

  lp.sense(lp.MAX);

  //Testing the problem retrieving routines
  check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!");
  check(lp.sense() == lp.MAX,"This is a maximization!");
  check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!");
  check(lp.colLowerBound(x1)==0,
        "The lower bound for variable x1 should be 0.");
  check(lp.colUpperBound(x1)==LpSolver::INF,
        "The upper bound for variable x1 should be infty.");
  check(lp.rowLowerBound(upright) == -LpSolver::INF,
        "The lower bound for the first row should be -infty.");
  check(lp.rowUpperBound(upright)==1,
        "The upper bound for the first row should be 1.");
  LpSolver::Expr e = lp.row(upright);
  check(e[x1] == 1, "The first coefficient should 1.");
  check(e[x2] == 2, "The second coefficient should 1.");

  lp.row(upright, x1+x2 <=1);
  e = lp.row(upright);
  check(e[x1] == 1, "The first coefficient should 1.");
  check(e[x2] == 1, "The second coefficient should 1.");

  LpSolver::DualExpr de = lp.col(x1);
  check(  de[upright] == 1, "The first coefficient should 1.");

  LpSolver* clp = lp.cloneSolver();

  //Testing the problem retrieving routines
  check(clp->objCoeff(x1)==1,"First term should be 1 in the obj function!");
  check(clp->sense() == clp->MAX,"This is a maximization!");
  check(clp->coeff(upright,x1)==1,"The coefficient in question is 1!");
  //  std::cout<<lp.colLowerBound(x1)<<std::endl;
  check(clp->colLowerBound(x1)==0,
        "The lower bound for variable x1 should be 0.");
  check(clp->colUpperBound(x1)==LpSolver::INF,
        "The upper bound for variable x1 should be infty.");

  check(lp.rowLowerBound(upright)==-LpSolver::INF,
        "The lower bound for the first row should be -infty.");
  check(lp.rowUpperBound(upright)==1,
        "The upper bound for the first row should be 1.");
  e = clp->row(upright);
  check(e[x1] == 1, "The first coefficient should 1.");
  check(e[x2] == 1, "The second coefficient should 1.");

  de = clp->col(x1);
  check(de[upright] == 1, "The first coefficient should 1.");

  delete clp;

  //Maximization of x1+x2
  //over the triangle with vertices (0,0) (0,1) (1,0)
  double expected_opt=1;
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);

  //Minimization
  lp.sense(lp.MIN);
  expected_opt=0;
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);

  //Vertex (-1,0) instead of (0,0)
  lp.colLowerBound(x1, -LpSolver::INF);
  expected_opt=-1;
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);

  //Erase one constraint and return to maximization
  lp.erase(upright);
  lp.sense(lp.MAX);
  expected_opt=LpSolver::INF;
  solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt);

  //Infeasibilty
  lp.addRow(x1+x2 <=-2);
  solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt);

}

int main()
{
  LpSkeleton lp_skel;
  lpTest(lp_skel);

#ifdef HAVE_GLPK
  {
    GlpkLp lp_glpk1,lp_glpk2;
    lpTest(lp_glpk1);
    aTest(lp_glpk2);
  }
#endif

#ifdef HAVE_CPLEX
  try {
    CplexLp lp_cplex1,lp_cplex2;
    lpTest(lp_cplex1);
    aTest(lp_cplex2);
  } catch (CplexEnv::LicenseError& error) {
#ifdef LEMON_FORCE_CPLEX_CHECK
    check(false, error.what());
#else
    std::cerr << error.what() << std::endl;
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
#endif
  }
#endif

#ifdef HAVE_SOPLEX
  {
    SoplexLp lp_soplex1,lp_soplex2;
    lpTest(lp_soplex1);
    aTest(lp_soplex2);
  }
#endif

#ifdef HAVE_CLP
  {
    ClpLp lp_clp1,lp_clp2;
    lpTest(lp_clp1);
    aTest(lp_clp2);
  }
#endif

  return 0;
}