File: basicmodelclasses.xml

package info (click to toggle)
clp 1.16.11%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,116 kB
  • ctags: 6,811
  • sloc: cpp: 178,972; sh: 8,845; xml: 3,682; makefile: 455; ansic: 81
file content (717 lines) | stat: -rw-r--r-- 26,310 bytes parent folder | download | duplicates (11)
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
<?xml version="1.0" encoding="ISO-8859-1"?>
  <chapter id="basicmodelclasses">
  <title>
  Basic Model Classes
  </title>
  <section id="hierarchy">
  <title>
  Hierarchy
  </title>
  <para>
  The basic CLP model class hierarchy is simple.  The top three levels of the 
  hierarchy are depicted in the figure below. The first two levels  (i.e.
  <classname>ClpModel</classname>, <classname>ClpSimplex</classname>,
  <classname>ClpInterior</classname>) contain all the problem data which define
  a model (that is, a problem instance). The third level contains most of the 
  algorithmic aspects of CLP.  There is a fourth level (for models with more general
  objectives than linear ones), but a description of it is beyond the current scope
  of this document.
  </para>
  <mediaobject>
    <!-- Caption doesn't line-up nicely in HTML, leave out for now
    <caption align="top">
      <para>
  	CLP Basic Classes
      </para>
    </caption>
    -->
    <imageobject>
      <imagedata fileref="figures/clpbasicmodelhier.gif" format="GIF"/>
    </imageobject>
  </mediaobject>
  <!-- Not appropriate here and not entirely correct as worded!
  <para>
  The class <classname>ClpModel</classname> contains most of the  problem data.
  There may be a few pieces of data which could be elsewhere but which are
  permanent and so they are here.  The main example of this is a status array:
  it makes the most sense for Simplex but has use for crossing over from any
  solution.
  </para>
  <para>
  <classname>ClpSimplex</classname> inherits from
  <classname>ClpModel</classname>, as does <classname>ClpInterior</classname>.
  Extra data is specific to the Simplex Algorithm and can be transient, e.g.
  scaling arrays.  Normally a user will just be dealing with the
  <classname>ClpSimplex</classname> class and not with the
  <classname>ClpModel</classname> class.
  </para>
  -->
  <para>
  Most Simplex users need only concern themselves with the classes
  <classname>ClpModel</classname> and <classname>ClpSimplex</classname>.  There
  are algorithm-specific classes which inherit from
  <classname>ClpSimplex</classname> (e.g. <classname>ClpSimplexDual</classname>
  and <classname>ClpSimplexPrimal</classname>), but they have no member data and
  rarely need be visible to the user.  These  classes are cast at algorithm
  time.  So, for example, after instantiating an object
  <userinput>model</userinput> of type <classname>ClpSimplex</classname>,
  a user only need call <userinput>model.dual()</userinput> to invoke the dual
  simplex method.
  </para>
  </section>
  <section id="firstexample">
  <title>
  First Example
  </title>
  <para>
  Below is our first CLP sample program.  It is short enough to present in full
  (this code can be found in the CLP Samples directory, see
  <xref linkend="moreexamples"/>).  Most of the remaining examples in this Guide
  will take the form of small code fragments.
  </para>
  <example>
  <title>minimum.cpp</title>
  <programlisting>
  <![CDATA[  
// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.

#include "ClpSimplex.hpp"
int main (int argc, const char *argv[])
{
  ClpSimplex  model;
  int status;
  if (argc<2)
    status=model.readMps("../../Mps/Sample/p0033.mps");
  else
    status=model.readMps(argv[1]);
  if (!status) {
    model.primal();
  }
  return 0;
} 
  ]]>   
  </programlisting>
  </example>
  <para>
  This sample program creates a  <classname>ClpSimplex</classname> model,
  reads an MPS file, and if there are no errors, solves it using the primal
  algorithm.  The program is easy to follow, but it is not terribly useful:
  it does not attempt to inspect the results of the solve.  There are two main
  kinds of results: a &quot;status&quot; describing what happened to the model
  during the solve, and arrays filled with solution values.  Both will be
  addressed in this chapter.
  </para>
  </section>
  <section id="gettingsolution">
  <title>
  Getting at the Solution
  </title>
  <para>
  It is often the case with CLP that there is more than one way to do something.
  This is a consequence of CLP's mixed heritage as a child of 
  <ulink url="http://www-306.ibm.com/software/data/bi/osl/">OSL</ulink>
  and a cousin of <ulink url="http://www.coin-or.org/faqs.html#OSI">OSI</ulink>.
  Finding the status of a model exemplifies this situation.
  </para>
  <para>
  The OSI way to check for optimality is to call model.isProvenOptimal().  Also
  available are <function>isProvenPrimalInfeasible()</function>,
  <function>isProvenDualInfeasible()</function>,
  <function>isPrimalObjectiveLimitReached()</function>,
  <function>isDualObjectiveLimitReached()</function>,
  <function>isIterationLimitReached()</function> or the feared
  <function>isAbandoned()</function>.  Should one prefer the OSL way of doing
  things, model.status() returns as it would in OSL, so 0 means optimal,
  1 means  primal infeasible etc.
  </para>
  <para>
  Similarly, to pick up the solution values, one could inhabit the virtuous
  world of OSI, or the not-quite-so-virtuous world of OSL and &quot;pure&quot;
  CLP.  By this it is meant that const and non-const forms of arrays are used,
  respectively.  It is easier to deal with the non-const versions, so most of
  the elaborate algorithms in CLP and its
  <link linkend="moresamples">Samples</link> use them.
  </para>
  <table frame="none">
  <title>
  Methods for getting solution information
  </title>
  <tgroup cols="3">
  <thead>
    <row>
      <entry>
      Purpose
      </entry>
      <entry>
      OSI-style (virtuous)
      </entry>
      <entry>
      CLP-style (less virtuous)
      </entry>
    </row>
  </thead>
  <tbody>
    <row>
      <entry align="left" valign="top">
      Primal column solution
      </entry>
      <entry align="left" valign="top">
      <function>const double * getColSolution()</function>
      </entry>
      <entry align="left" valign="top">
      <function>double * primalColumnSolution()</function>
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      Dual row solution
      </entry>
      <entry align="left" valign="top">
      <function>const double * getRowPrice()</function>
      </entry>
      <entry align="left" valign="top">
      <function>double * dualColumnSolution()</function>
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      Primal row solution
      </entry>
      <entry align="left" valign="top">
      <function>const double * getRowActivity()</function>
      </entry>
      <entry align="left" valign="top">
      <function>double * primalRowSolution()</function>
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      Dual row solution
      </entry>
      <entry align="left" valign="top">
      <function>const double * getReducedCost()</function>
      </entry>
      <entry align="left" valign="top">
      <function>double * dualColumnSolution()</function>
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      Number of rows in model
      </entry>
      <entry align="left" valign="top">
      <function>int getNumRows()</function>
      </entry>
      <entry align="left" valign="top">
      <function>int numberRows()</function>
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      Number of columns in model
      </entry>
      <entry align="left" valign="top">
      <function>int getNumCols()</function>
      </entry>
      <entry align="left" valign="top">
      <function>int numberColumns()</function>
      </entry>
    </row>
  </tbody>
  </tgroup>
  </table>

  <para>
  The reader  may have noted a preference for &quot;number&quot; over
  &quot;num&quot; and &quot;column&quot; over &quot;col&quot;.  This may be a
  reaction to when one of the authors was young and 5 or 6 letters was the
  maximum in FORTRAN for any name or to early days with OSL when seven characters
  were allowed but the first three had to be &quot;ekk&quot;!  
  </para>
  <para>
  Using the above-listed functions, our
  <link linkend="firstexample">initial example</link> might be continued as follows:
  </para>
  <example>
  <title>
  Possible extension of minimum.cpp
  </title>
  <programlisting>
  <![CDATA[  
  int numberRows = model.numberRows();
  double * rowPrimal = model.primalRowSolution();
  double * rowDual = model.dualRowSolution();

  int iRow;

  for (iRow=0;iRow<numberRows;iRow++) 	
    printf("Row %d, primal %g, dual %g\n",iRow,
	rowPrimal[iRow],rowDual[iRow]);
	
  int numberColumns = model.numberColumns();
  double * columnPrimal = model.primalColumnSolution();
  double * columnDual = model.dualColumnSolution();

  int iColumn;

  for (iColumn=0;iColumn<numberColumns;iColumn++) 	
    printf("Column %d, primal %g, dual %g\n",iColumn,
	columnPrimal[iColumn],columnDual[iColumn]);
  ]]>
  </programlisting>
  </example>
  <para>
  This code sample would pretty-print information about the model's primal and
  dual solutions.  How to additionally print row and column names is
  illustrated in the <filename>defaults.cpp</filename> file in the
  &quot;Samples&quot; directory (the Samples are properly addressed
  in <xref linkend="moreexamples" />).  This sample is also useful as it
  explicitly performs default actions (e.g. it sets the primal feasiblility
  tolerance value to the default value).
  </para>
  <para>
  The remainder of this chapter will show  more of the basic CLP tasks a user
  might wish to perform.  Apart from presolve we will only be looking at actions
  which can be performed when including the single header file
  <filename>COIN/Clp/include/ClpSimplex.hpp</filename>.
  </para>
  </section>
  <section id="buildandmodify">
  <title>
  Building and Modifying a Model
  </title>
  <para>
  Rather than reading a model from an MPS file we can load a model from arrays
  in memory.  There are various <function>loadProblem</function> methods which
  are similar to those in OSI.  It is easy to add more such methods to CLP if the need arises.
  </para>
  <para>We can copy in integer information by 
  <function>copyInIntegerInformation(const&nbsp;char&nbsp;*&nbsp;array)</function> where array
  is 0 or 1 to say integer and we can drop existing information by
  <function>deleteIntegerInformation()</function>.  There are various ways of
  changing the size of a model.  The simplest is by the use of the method
  <function>resize(newNumberRows,newNumberColumns)</function> - this will either
  truncate the model or add &quot;default&quot; rows or columns - a default row
  has lower bound of -infinity and upper bound of +infinity, while a default
  column has zero cost, zero lower bound and an upper bound of +infinity.
  </para>
  <para>
  Normally we would use <function>deleteRows</function>,
  <function>addRows</function>, <function>deleteColumns</function> and
  <function>addColumns</function>, where the <function>add</function> methods
  will also add in the elements.  A potentially very useful way of modifying a model is strictly a
  constructor.  Given a large model and a list of rows and a list of columns it
  constructs the model as a subset of the large model.  It is possible to change
  the order of the columns/rows and to duplicate columns/rows.  So a list of
  columns 4,4,1,0 will create a new model where the first two columns are copies
  of column 4 in original model and the next two are the first two of original
  model in reverse order.  This can be useful to form a model with piecewise
  linear costs by duplicating columns and then modifying bounds and costs.
  </para>
  </section>
  <section id="tolerances">
  <title>Tolerances</title>
  <para>
  There are set and get methods for tolerances, for example,
  <function>double&nbsp;primalTolerance()</function> and
  <function>setPrimalTolerance(double)</function>.  Assuming that one has a
  minimization problem, an individual variable is deemed primal feasible if it
  is less than the tolerance referred to by these methods below its lower bound
  and less than it above its upper bound.  Similarly for dual tolerances, a
  variable is deemed to be dual feasible if its reduced cost is greater than
  minus the tolerance or its distance to the upper bound is less than primal
  tolerance and the reduced cost is less than plus the tolerance or the distance
  to lower bound is less than primal tolerance.  In short, this is complementarity
  conditions adadpted for tolerances and simple lower and upper bounds.(Note
  that the above was stated as for minimization; signs are reversed for
  maximization.)
  </para>
  </section>
  <section id="setsandgets">
  <title>Some Useful Set and Get Methods</title>
  <table frame="none">
  <title>Some Useful Set and Get Methods</title>
    <tgroup cols="2">
    <thead>
    <row>
    <entry>
    Method(s)
    </entry>
    <entry>
    Description
    </entry>
    </row>
    </thead>
    <tbody>
    <row>
      <entry align="left" valign="top">
      <function>setMaximumIterations(int value)</function><sbr/>
      <function>int maximumIterations()</function><sbr/>
      <function>setMaximumSeconds(double value)</function><sbr/>
      <function>double maximumIterations()</function>
      </entry>
      <entry align="left" valign="top">
      These methods tell CLP to stop after a given number of iterations or
      seconds (and returns these values).
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>double&nbsp;objectiveValue()</function>
      </entry>
      <entry align="left" valign="top">
      This method returns the objective value.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>const&nbsp;double&nbsp;*&nbsp;getObjCoefficients()</function><sbr/>
      <function>double&nbsp;*&nbsp;objective()</function>
      </entry>
      <entry align="left" valign="top">
      These methods return the objective coefficients.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>const&nbsp;double&nbsp;*&nbsp;getRowLower()</function><sbr/>
      <function>double&nbsp;*&nbsp;rowLower()</function><sbr/>
      <function>const&nbsp;double&nbsp;*&nbsp;getRowUpper()</function><sbr/>
      <function>double&nbsp;*&nbsp;rowUpper()</function><sbr/>
      <function>const&nbsp;double&nbsp;*&nbsp;getColLower()</function><sbr/>
      <function>double&nbsp;*&nbsp;columnLower()</function><sbr/>
      <function>const&nbsp;double&nbsp;*&nbsp;getColUpper()</function><sbr/>
      <function>double&nbsp;*&nbsp;columnUpper()</function>
      </entry>
      <entry align="left" valign="top">
      These methods give lower and upper bounds on row and column activities.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>double * infeasibilityRay()</function><sbr/>
      <function>double * unboundedRay()</function>
      </entry>
      <entry align="left" valign="top">
      If the problem was primal or dual infeasible, these methods will give a
      pointer to a ray proving infeasibility.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>CoinPackMatrix * matrix()</function>
      </entry>
      <entry align="left" valign="top">
      There are more options as the user has great flexibility in how the problem
      matrix is stored, but the default matrix class is
      <classname>CoinPackedMatrix</classname> (see 
      <xref linkend="matrixclasses"/>).
      So we have that this method returns a pointer to a
      <classname>CoinPackedMatrix</classname> which can be further manipulated.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>CoinBigIndex&nbsp;getNumElements()</function>
      <footnote>
        <para>
	<type>CoinBigIndex</type> is a <function>typedef</function> which in
	most cases is the same as <type>int</type>.
	</para>
      </footnote>
      </entry>
      <entry align="left" valign="top">
      Returns the number of elements in the problem matrix.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>void setOptimizationDirection(double&nbsp;value)</function><sbr/>
      <function>double optimizationDirection()</function>
      </entry>
      <entry align="left" valign="top">
      These methods set and get the objective sense.  The parameter
      <parameter>value</parameter> should be +1 to minimize, -1 to maximize,
      and 0 to ignore.
      </entry>
    </row>
    </tbody>
  </tgroup>
  </table>
  </section>
  <section id="simplexspecific">
  <title>
  Simplex-specific Methods
  </title>
  <para>
  Some of the most commonly-used methods when working with Simplex are listed in
  the table below.
  </para>
  <table frame="none">
  <title>Common Simplex-specific methods</title>
    <tgroup cols="2">
    <thead>
    <row>
    <entry>
    Method(s)
    </entry>
    <entry>
    Description
    </entry>
    </row>
    </thead>
    <tbody>
    <row>
      <entry align="left" valign="top">
      <function>primal(int&nbsp;mode=0)</function>
      </entry>
      <entry align="left" valign="top">
      This applies the primal algorithm. If <parameter>mode</parameter> is
      set to the default of 0, then the method uses the status variables to
      determine basis and solution. If <parameter>mode</parameter> is 1 then
      the method does a values pass so variables not in basis are given their
      current values and one pass of variables is done to clean up the basis
      with an equal or better objective value.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>dual(int&nbsp;mode=0)</function>
      </entry>
      <entry align="left" valign="top">
      This applies the dual algorithm. if <parameter>mode</parameter> is set
      to the default of 0, then the method uses the status variables to
      determine basis and solution.  If <parameter>mode</parameter> is 1 then
      the method uses input duals and does a values pass so one pass of basic
      variables is done to clean up the duals with an equal or better objective
      value.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>scaling(int&nbsp;mode=1)</function>
      </entry>
      <entry align="left" valign="top">
      This method toggles scaling on (<parameter>mode</parameter> set to 1)
      and off (<parameter>mode</parameter> set to 0).
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>int&nbsp;crash(double&nbsp;gap,int&nbsp;mode)</function>
      </entry>
      <entry align="left" valign="top">
      This method attemps to improve on an all slack basis.
      For dual this will move variables to the dual feasible bound
      if the gap between bounds is less than <parameter>gap</parameter>.  Setting
      <parameter>mode</parameter> to 0 guesses which algorithm is better, while
      a value of 1 or 2 will result in more work being done.  The return code is
      0 if the basis was not slacks in first case, it is negative if dual is
      preferred or positive if primal.  &plusmn;1 means an all slack basis seemed
      best, while &plusmn;2 means some work was done. 
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>perturb(int&nbsp;mode)</function>
      </entry>
      <entry align="left" valign="top">
      This method toggles perturbation on (<parameter>mode</parameter> set to 1)
      and off (<parameter>mode</parameter> set to 0).  It should be considered
      a work in progress, although on some problems it gives very good results.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>factorizationFrequency()</function><sbr/>
      <function>setFactorizationFrequency(int&nbsp;value)</function>
      </entry>
      <entry align="left" valign="top">
      These are &quot;get&quot; and &quot;set&quot; methods for the basis matrix
      factorization frequency.  The default is to refactor every 200 iterations,
      but it may make more sense to use something such as 100 + the number of
      rows divided by 50.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>dualBound()</function><sbr/>
      <function>setDualBound(double&nbsp;value)</function>
      </entry>
      <entry align="left" valign="top">
      These are &quot;get&quot; and &quot;set&quot; methods for the
      &quot;dual&nbsp;bound&quot;.  The CLP dual algorithm declares all problems
      to be dual feasible by putting non-basic variables to correct bounds for
      the reduced cost.  If the gap between the bounds is too big then it
      pretends the gap is only the value specified by this set method.
      In essence, this gives a composite dual rather than a pure
      Phase&nbsp;I- Phase&nbsp;II method.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>infeasibilityCost()</function><sbr/>
      <function>setInfeasibilityCost(double&nbsp;value)</function>
      </entry>
      <entry align="left" valign="top">
      These are the primal analogs to the &quot;dual&nbsp;bound&quot; methods.
      </entry>
    </row>
    <row>
      <entry align="left" valign="top">
      <function>numberPrimalInfeasibilities()</function><sbr/>
      <function>sumPrimalInfeasibilities()</function>
      </entry>
      <entry align="left" valign="top">
      After a solve, there may be infeasibilities.  These methods serve to
      check for said infeasibilities.  One could check the solution explicitly
      as well.  For a code fragement illustrating this, see
      <xref linkend="presolveexample"/>.
      </entry>
    </row>
    </tbody>
  </tgroup>
  </table>
  </section>
  <section id="presolve">
  <title>
  Presolve
  </title>
  <para>
  The header file for the use of CLP's presolve functionality is
  <filename>COIN/Clp/include/Presolve.hpp</filename>.  The sample program below
  illustrates some of the possibilities offered by CLP's presolve:
  </para>
  <example id="presolveexample">
  <title>Presolve code fragment</title>
  <programlisting>
#include "ClpSimplex.hpp"
#include "ClpPresolve.hpp"
int main (int argc, const char *argv[])
{
  ClpSimplex model; 
  model.readMps("../../Mps/Sample/p0033.mps"); // initialized by readMps or whatever 
  ClpPresolve presolveInfo; 
  ClpSimplex * presolvedModel = presolveInfo.presolvedModel(model); 
  // at this point we have original model and a new model.  The  information
  // on the operations done is in presolveInfo 
  if (presolvedModel) { 
    // was not found to be infeasible - so lets solve 
    // if presolvedModel was NULL then it was primal infeasible and ... 
    presolvedModel->dual(); // or whatever else we wish to do 
    presolveInfo.postsolve(true);  // the true updates status arrays in original       
    /* If the presolved model was optimal then so should the 
       original be.           
       We can use checkSolution and test feasibility */ 
    model.checkSolution();         
    if (model.numberDualInfeasibilities()|| 
	model.numberPrimalInfeasibilities()) 
      printf("%g dual %g(%d) Primal %g(%d)\n", 
	     model.objectiveValue(), 
	     model.sumDualInfeasibilities(), 
	     model.numberDualInfeasibilities(), 
	     model.sumPrimalInfeasibilities(), 
	     model.numberPrimalInfeasibilities()); 
    // Due to tolerances we can not guarantee that so you may wish to throw in
    model.primal(1); 
  }
}   
  </programlisting>
  </example>
  <para>
  Presolve has a few more options which can be found in the header file, for
  example whether to treat as an integer problem or whether to keep row and
  column names.
  </para>
  </section>
  <section id="statusarray">
  <title>Status Array</title>
  <para>
  The astute reader may have noticed that the status array has been mentioned
  once or twice.  The beginning user will not need to look at it   Nevertheless,
  for completeness the status of a variable can be found and set as shown below.
  The possible state of a variable are listed in the following table (each may
  have to be preceded by ClpSimplex::):
  </para>
  <table frame="none">
  <title>Possible states of a variable</title>
    <tgroup cols="2">
      <thead>
        <row>
	  <entry>
	  <type>Status</type><footnote><para><type>Status</type>
	    is an enumeration.</para></footnote>
	  </entry>
	  <entry>
	  Description
	  </entry>
	</row>
      </thead>
      <tbody>
        <row>
	  <entry align="left" valign="top">
	  <constant>basic</constant>
	  </entry>
	  <entry align="left" valign="top">
	  In basis
	  </entry>
        </row>
        <row>
	  <entry align="left" valign="top">
	  <constant>isFree</constant>
	  </entry>
	  <entry align="left" valign="top">
	  Not in basis, has infinite bounds
	  </entry>
        </row>
        <row>
	  <entry align="left" valign="top">
	  <constant>isFixed</constant>
	  </entry>
	  <entry align="left" valign="top">
	  Not in basis, bounds are equal
	  </entry>
        </row>
        <row>
	  <entry align="left" valign="top">
	  <constant>atUpperBound</constant>
	  </entry>
	  <entry align="left" valign="top">
	  At upper bound, not in basis
	  </entry>
        </row>
        <row>
	  <entry align="left" valign="top">
	  <constant>atLowerBound</constant>
	  </entry>
	  <entry align="left" valign="top">
	  At lower bound, not in basis
	  </entry>
        </row>
        <row>
	  <entry align="left" valign="top">
	  <constant>superBasic</constant>
	  </entry>
	  <entry align="left" valign="top">
	  Between bounds, but not basic or free
	  </entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  <para>
  To get or set the status of a variable is a simple task:
  </para>
  <programlisting>
  // Get row status...
  Status status=model.getRowStatus(sequenceNumber)
  // ... or get column status.
  Status status=model.getColumnStatus(sequenceNumber)
  // Set row status to basic (for example)...
  model.setRowStatus(sequenceNumber,ClpSimplex::basic)
  // ... or column status to basic.
  model.setColumnStatus(sequenceNumber,ClpSimplex::basic)
  </programlisting>
  </section>
  </chapter>