source: trunk/Clp/src/ClpSimplex.hpp @ 1533

Last change on this file since 1533 was 1533, checked in by forrest, 11 years ago

make it easier to play with multiple Lp solutions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 61.4 KB
Line 
1/* $Id: ClpSimplex.hpp 1533 2010-03-23 15:26:32Z forrest $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4
5/*
6   Authors
7
8   John Forrest
9
10 */
11#ifndef ClpSimplex_H
12#define ClpSimplex_H
13
14#include <iostream>
15#include <cfloat>
16#include "ClpModel.hpp"
17#include "ClpMatrixBase.hpp"
18#include "ClpSolve.hpp"
19class ClpDualRowPivot;
20class ClpPrimalColumnPivot;
21class ClpFactorization;
22class CoinIndexedVector;
23class ClpNonLinearCost;
24class ClpNodeStuff;
25class CoinStructuredModel;
26class OsiClpSolverInterface;
27class CoinWarmStartBasis;
28class ClpDisasterHandler;
29class ClpConstraint;
30
31/** This solves LPs using the simplex method
32
33    It inherits from ClpModel and all its arrays are created at
34    algorithm time. Originally I tried to work with model arrays
35    but for simplicity of coding I changed to single arrays with
36    structural variables then row variables.  Some coding is still
37    based on old style and needs cleaning up.
38
39    For a description of algorithms:
40
41    for dual see ClpSimplexDual.hpp and at top of ClpSimplexDual.cpp
42    for primal see ClpSimplexPrimal.hpp and at top of ClpSimplexPrimal.cpp
43
44    There is an algorithm data member.  + for primal variations
45    and - for dual variations
46
47*/
48
49class ClpSimplex : public ClpModel {
50     friend void ClpSimplexUnitTest(const std::string & mpsDir);
51
52public:
53     /** enums for status of various sorts.
54         First 4 match CoinWarmStartBasis,
55         isFixed means fixed at lower bound and out of basis
56     */
57     enum Status {
58          isFree = 0x00,
59          basic = 0x01,
60          atUpperBound = 0x02,
61          atLowerBound = 0x03,
62          superBasic = 0x04,
63          isFixed = 0x05
64     };
65     // For Dual
66     enum FakeBound {
67          noFake = 0x00,
68          lowerFake = 0x01,
69          upperFake = 0x02,
70          bothFake = 0x03
71     };
72
73     /**@name Constructors and destructor and copy */
74     //@{
75     /// Default constructor
76     ClpSimplex (bool emptyMessages = false  );
77
78     /** Copy constructor. May scale depending on mode
79         -1 leave mode as is
80         0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later)
81     */
82     ClpSimplex(const ClpSimplex & rhs, int scalingMode = -1);
83     /** Copy constructor from model. May scale depending on mode
84         -1 leave mode as is
85         0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later)
86     */
87     ClpSimplex(const ClpModel & rhs, int scalingMode = -1);
88     /** Subproblem constructor.  A subset of whole model is created from the
89         row and column lists given.  The new order is given by list order and
90         duplicates are allowed.  Name and integer information can be dropped
91         Can optionally modify rhs to take into account variables NOT in list
92         in this case duplicates are not allowed (also see getbackSolution)
93     */
94     ClpSimplex (const ClpModel * wholeModel,
95                 int numberRows, const int * whichRows,
96                 int numberColumns, const int * whichColumns,
97                 bool dropNames = true, bool dropIntegers = true,
98                 bool fixOthers = false);
99     /** Subproblem constructor.  A subset of whole model is created from the
100         row and column lists given.  The new order is given by list order and
101         duplicates are allowed.  Name and integer information can be dropped
102         Can optionally modify rhs to take into account variables NOT in list
103         in this case duplicates are not allowed (also see getbackSolution)
104     */
105     ClpSimplex (const ClpSimplex * wholeModel,
106                 int numberRows, const int * whichRows,
107                 int numberColumns, const int * whichColumns,
108                 bool dropNames = true, bool dropIntegers = true,
109                 bool fixOthers = false);
110     /** This constructor modifies original ClpSimplex and stores
111         original stuff in created ClpSimplex.  It is only to be used in
112         conjunction with originalModel */
113     ClpSimplex (ClpSimplex * wholeModel,
114                 int numberColumns, const int * whichColumns);
115     /** This copies back stuff from miniModel and then deletes miniModel.
116         Only to be used with mini constructor */
117     void originalModel(ClpSimplex * miniModel);
118     /** Array persistence flag
119         If 0 then as now (delete/new)
120         1 then only do arrays if bigger needed
121         2 as 1 but give a bit extra if bigger needed
122     */
123     void setPersistenceFlag(int value);
124     /// Save a copy of model with certain state - normally without cuts
125     void makeBaseModel();
126     /// Switch off base model
127     void deleteBaseModel();
128     /// See if we have base model
129     inline ClpSimplex *  baseModel() const {
130          return baseModel_;
131     }
132     /** Reset to base model (just size and arrays needed)
133         If model NULL use internal copy
134     */
135     void setToBaseModel(ClpSimplex * model = NULL);
136     /// Assignment operator. This copies the data
137     ClpSimplex & operator=(const ClpSimplex & rhs);
138     /// Destructor
139     ~ClpSimplex (  );
140     // Ones below are just ClpModel with some changes
141     /** Loads a problem (the constraints on the
142           rows are given by lower and upper bounds). If a pointer is 0 then the
143           following values are the default:
144           <ul>
145             <li> <code>colub</code>: all columns have upper bound infinity
146             <li> <code>collb</code>: all columns have lower bound 0
147             <li> <code>rowub</code>: all rows have upper bound infinity
148             <li> <code>rowlb</code>: all rows have lower bound -infinity
149         <li> <code>obj</code>: all variables have 0 objective coefficient
150           </ul>
151       */
152     void loadProblem (  const ClpMatrixBase& matrix,
153                         const double* collb, const double* colub,
154                         const double* obj,
155                         const double* rowlb, const double* rowub,
156                         const double * rowObjective = NULL);
157     void loadProblem (  const CoinPackedMatrix& matrix,
158                         const double* collb, const double* colub,
159                         const double* obj,
160                         const double* rowlb, const double* rowub,
161                         const double * rowObjective = NULL);
162
163     /** Just like the other loadProblem() method except that the matrix is
164       given in a standard column major ordered format (without gaps). */
165     void loadProblem (  const int numcols, const int numrows,
166                         const CoinBigIndex* start, const int* index,
167                         const double* value,
168                         const double* collb, const double* colub,
169                         const double* obj,
170                         const double* rowlb, const double* rowub,
171                         const double * rowObjective = NULL);
172     /// This one is for after presolve to save memory
173     void loadProblem (  const int numcols, const int numrows,
174                         const CoinBigIndex* start, const int* index,
175                         const double* value, const int * length,
176                         const double* collb, const double* colub,
177                         const double* obj,
178                         const double* rowlb, const double* rowub,
179                         const double * rowObjective = NULL);
180     /** This loads a model from a coinModel object - returns number of errors.
181         If keepSolution true and size is same as current then
182         keeps current status and solution
183     */
184     int loadProblem (  CoinModel & modelObject, bool keepSolution = false);
185     /// Read an mps file from the given filename
186     int readMps(const char *filename,
187                 bool keepNames = false,
188                 bool ignoreErrors = false);
189     /// Read GMPL files from the given filenames
190     int readGMPL(const char *filename, const char * dataName,
191                  bool keepNames = false);
192     /// Read file in LP format from file with name filename.
193     /// See class CoinLpIO for description of this format.
194     int readLp(const char *filename, const double epsilon = 1e-5);
195     /** Borrow model.  This is so we dont have to copy large amounts
196         of data around.  It assumes a derived class wants to overwrite
197         an empty model with a real one - while it does an algorithm.
198         This is same as ClpModel one, but sets scaling on etc. */
199     void borrowModel(ClpModel & otherModel);
200     void borrowModel(ClpSimplex & otherModel);
201     /// Pass in Event handler (cloned and deleted at end)
202     void passInEventHandler(const ClpEventHandler * eventHandler);
203     /// Puts solution back into small model
204     void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int * whichColumn);
205     /** Load nonlinear part of problem from AMPL info
206         Returns 0 if linear
207         1 if quadratic objective
208         2 if quadratic constraints
209         3 if nonlinear objective
210         4 if nonlinear constraints
211         -1 on failure
212     */
213     int loadNonLinear(void * info, int & numberConstraints,
214                       ClpConstraint ** & constraints);
215     //@}
216
217     /**@name Functions most useful to user */
218     //@{
219     /** General solve algorithm which can do presolve.
220         See  ClpSolve.hpp for options
221      */
222     int initialSolve(ClpSolve & options);
223     /// Default initial solve
224     int initialSolve();
225     /// Dual initial solve
226     int initialDualSolve();
227     /// Primal initial solve
228     int initialPrimalSolve();
229/// Barrier initial solve
230     int initialBarrierSolve();
231     /// Barrier initial solve, not to be followed by crossover
232     int initialBarrierNoCrossSolve();
233     /** Dual algorithm - see ClpSimplexDual.hpp for method.
234         ifValuesPass==2 just does values pass and then stops.
235
236         startFinishOptions - bits
237         1 - do not delete work areas and factorization at end
238         2 - use old factorization if same number of rows
239         4 - skip as much initialization of work areas as possible
240             (based on whatsChanged in clpmodel.hpp) ** work in progress
241         maybe other bits later
242     */
243     int dual(int ifValuesPass = 0, int startFinishOptions = 0);
244     // If using Debug
245     int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0);
246     /** Primal algorithm - see ClpSimplexPrimal.hpp for method.
247         ifValuesPass==2 just does values pass and then stops.
248
249         startFinishOptions - bits
250         1 - do not delete work areas and factorization at end
251         2 - use old factorization if same number of rows
252         4 - skip as much initialization of work areas as possible
253             (based on whatsChanged in clpmodel.hpp) ** work in progress
254         maybe other bits later
255     */
256     int primal(int ifValuesPass = 0, int startFinishOptions = 0);
257     /** Solves nonlinear problem using SLP - may be used as crash
258         for other algorithms when number of iterations small.
259         Also exits if all problematical variables are changing
260         less than deltaTolerance
261     */
262     int nonlinearSLP(int numberPasses, double deltaTolerance);
263     /** Solves problem with nonlinear constraints using SLP - may be used as crash
264         for other algorithms when number of iterations small.
265         Also exits if all problematical variables are changing
266         less than deltaTolerance
267     */
268     int nonlinearSLP(int numberConstraints, ClpConstraint ** constraints,
269                      int numberPasses, double deltaTolerance);
270     /** Solves using barrier (assumes you have good cholesky factor code).
271         Does crossover to simplex if asked*/
272     int barrier(bool crossover = true);
273     /** Solves non-linear using reduced gradient.  Phase = 0 get feasible,
274         =1 use solution */
275     int reducedGradient(int phase = 0);
276     /// Solve using structure of model and maybe in parallel
277     int solve(CoinStructuredModel * model);
278     /** This loads a model from a CoinStructuredModel object - returns number of errors.
279         If originalOrder then keep to order stored in blocks,
280         otherwise first column/rows correspond to first block - etc.
281         If keepSolution true and size is same as current then
282         keeps current status and solution
283     */
284     int loadProblem (  CoinStructuredModel & modelObject,
285                        bool originalOrder = true, bool keepSolution = false);
286     /**
287        When scaling is on it is possible that the scaled problem
288        is feasible but the unscaled is not.  Clp returns a secondary
289        status code to that effect.  This option allows for a cleanup.
290        If you use it I would suggest 1.
291        This only affects actions when scaled optimal
292        0 - no action
293        1 - clean up using dual if primal infeasibility
294        2 - clean up using dual if dual infeasibility
295        3 - clean up using dual if primal or dual infeasibility
296        11,12,13 - as 1,2,3 but use primal
297
298        return code as dual/primal
299     */
300     int cleanup(int cleanupScaling);
301     /** Dual ranging.
302         This computes increase/decrease in cost for each given variable and corresponding
303         sequence numbers which would change basis.  Sequence numbers are 0..numberColumns
304         and numberColumns.. for artificials/slacks.
305         For non-basic variables the information is trivial to compute and the change in cost is just minus the
306         reduced cost and the sequence number will be that of the non-basic variables.
307         For basic variables a ratio test is between the reduced costs for non-basic variables
308         and the row of the tableau corresponding to the basic variable.
309         The increase/decrease value is always >= 0.0
310
311         Up to user to provide correct length arrays where each array is of length numberCheck.
312         which contains list of variables for which information is desired.  All other
313         arrays will be filled in by function.  If fifth entry in which is variable 7 then fifth entry in output arrays
314         will be information for variable 7.
315
316         If valueIncrease/Decrease not NULL (both must be NULL or both non NULL) then these are filled with
317         the value of variable if such a change in cost were made (the existing bounds are ignored)
318
319         Returns non-zero if infeasible unbounded etc
320     */
321     int dualRanging(int numberCheck, const int * which,
322                     double * costIncrease, int * sequenceIncrease,
323                     double * costDecrease, int * sequenceDecrease,
324                     double * valueIncrease = NULL, double * valueDecrease = NULL);
325     /** Primal ranging.
326         This computes increase/decrease in value for each given variable and corresponding
327         sequence numbers which would change basis.  Sequence numbers are 0..numberColumns
328         and numberColumns.. for artificials/slacks.
329         This should only be used for non-basic variabls as otherwise information is pretty useless
330         For basic variables the sequence number will be that of the basic variables.
331
332         Up to user to provide correct length arrays where each array is of length numberCheck.
333         which contains list of variables for which information is desired.  All other
334         arrays will be filled in by function.  If fifth entry in which is variable 7 then fifth entry in output arrays
335         will be information for variable 7.
336
337         Returns non-zero if infeasible unbounded etc
338     */
339     int primalRanging(int numberCheck, const int * which,
340                       double * valueIncrease, int * sequenceIncrease,
341                       double * valueDecrease, int * sequenceDecrease);
342     /** Write the basis in MPS format to the specified file.
343         If writeValues true writes values of structurals
344         (and adds VALUES to end of NAME card)
345
346         Row and column names may be null.
347         formatType is
348         <ul>
349         <li> 0 - normal
350         <li> 1 - extra accuracy
351         <li> 2 - IEEE hex (later)
352         </ul>
353
354         Returns non-zero on I/O error
355     */
356     int writeBasis(const char *filename,
357                    bool writeValues = false,
358                    int formatType = 0) const;
359     /** Read a basis from the given filename,
360         returns -1 on file error, 0 if no values, 1 if values */
361     int readBasis(const char *filename);
362     /// Returns a basis (to be deleted by user)
363     CoinWarmStartBasis * getBasis() const;
364     /// Passes in factorization
365     void setFactorization( ClpFactorization & factorization);
366     // Swaps factorization
367     ClpFactorization * swapFactorization( ClpFactorization * factorization);
368     /// Copies in factorization to existing one
369     void copyFactorization( ClpFactorization & factorization);
370     /** Tightens primal bounds to make dual faster.  Unless
371         fixed or doTight>10, bounds are slightly looser than they could be.
372         This is to make dual go faster and is probably not needed
373         with a presolve.  Returns non-zero if problem infeasible.
374
375         Fudge for branch and bound - put bounds on columns of factor *
376         largest value (at continuous) - should improve stability
377         in branch and bound on infeasible branches (0.0 is off)
378     */
379     int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false);
380     /** Crash - at present just aimed at dual, returns
381         -2 if dual preferred and crash basis created
382         -1 if dual preferred and all slack basis preferred
383          0 if basis going in was not all slack
384          1 if primal preferred and all slack basis preferred
385          2 if primal preferred and crash basis created.
386
387          if gap between bounds <="gap" variables can be flipped
388          ( If pivot -1 then can be made super basic!)
389
390          If "pivot" is
391          -1 No pivoting - always primal
392          0 No pivoting (so will just be choice of algorithm)
393          1 Simple pivoting e.g. gub
394          2 Mini iterations
395     */
396     int crash(double gap, int pivot);
397     /// Sets row pivot choice algorithm in dual
398     void setDualRowPivotAlgorithm(ClpDualRowPivot & choice);
399     /// Sets column pivot choice algorithm in primal
400     void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice);
401     /** For strong branching.  On input lower and upper are new bounds
402         while on output they are change in objective function values
403         (>1.0e50 infeasible).
404         Return code is 0 if nothing interesting, -1 if infeasible both
405         ways and +1 if infeasible one way (check values to see which one(s))
406         Solutions are filled in as well - even down, odd up - also
407         status and number of iterations
408     */
409     int strongBranching(int numberVariables, const int * variables,
410                         double * newLower, double * newUpper,
411                         double ** outputSolution,
412                         int * outputStatus, int * outputIterations,
413                         bool stopOnFirstInfeasible = true,
414                         bool alwaysFinish = false,
415                         int startFinishOptions = 0);
416     /// Fathom - 1 if solution
417     int fathom(void * stuff);
418     /** Do up to N deep - returns
419         -1 - no solution nNodes_ valid nodes
420         >= if solution and that node gives solution
421         ClpNode array is 2**N long.  Values for N and
422         array are in stuff (nNodes_ also in stuff) */
423     int fathomMany(void * stuff);
424     /// Double checks OK
425     double doubleCheck();
426     /// Starts Fast dual2
427     int startFastDual2(ClpNodeStuff * stuff);
428     /// Like Fast dual
429     int fastDual2(ClpNodeStuff * stuff);
430     /// Stops Fast dual2
431     void stopFastDual2(ClpNodeStuff * stuff);
432     /** Deals with crunch aspects
433         mode 0 - in
434              1 - out with solution
435          2 - out without solution
436         returns small model or NULL
437     */
438     ClpSimplex * fastCrunch(ClpNodeStuff * stuff, int mode);
439     //@}
440
441     /**@name Needed for functionality of OsiSimplexInterface */
442     //@{
443     /** Pivot in a variable and out a variable.  Returns 0 if okay,
444         1 if inaccuracy forced re-factorization, -1 if would be singular.
445         Also updates primal/dual infeasibilities.
446         Assumes sequenceIn_ and pivotRow_ set and also directionIn and Out.
447     */
448     int pivot();
449
450     /** Pivot in a variable and choose an outgoing one.  Assumes primal
451         feasible - will not go through a bound.  Returns step length in theta
452         Returns ray in ray_ (or NULL if no pivot)
453         Return codes as before but -1 means no acceptable pivot
454     */
455     int primalPivotResult();
456
457     /** Pivot out a variable and choose an incoing one.  Assumes dual
458         feasible - will not go through a reduced cost.
459         Returns step length in theta
460         Returns ray in ray_ (or NULL if no pivot)
461         Return codes as before but -1 means no acceptable pivot
462     */
463     int dualPivotResult();
464
465     /** Common bits of coding for dual and primal.  Return 0 if okay,
466         1 if bad matrix, 2 if very bad factorization
467
468         startFinishOptions - bits
469         1 - do not delete work areas and factorization at end
470         2 - use old factorization if same number of rows
471         4 - skip as much initialization of work areas as possible
472             (based on whatsChanged in clpmodel.hpp) ** work in progress
473         maybe other bits later
474
475     */
476     int startup(int ifValuesPass, int startFinishOptions = 0);
477     void finish(int startFinishOptions = 0);
478
479     /** Factorizes and returns true if optimal.  Used by user */
480     bool statusOfProblem(bool initial = false);
481     /// If user left factorization frequency then compute
482     void defaultFactorizationFrequency();
483     //@}
484
485     /**@name most useful gets and sets */
486     //@{
487     /// If problem is primal feasible
488     inline bool primalFeasible() const {
489          return (numberPrimalInfeasibilities_ == 0);
490     }
491     /// If problem is dual feasible
492     inline bool dualFeasible() const {
493          return (numberDualInfeasibilities_ == 0);
494     }
495     /// factorization
496     inline ClpFactorization * factorization() const {
497          return factorization_;
498     }
499     /// Sparsity on or off
500     bool sparseFactorization() const;
501     void setSparseFactorization(bool value);
502     /// Factorization frequency
503     int factorizationFrequency() const;
504     void setFactorizationFrequency(int value);
505     /// Dual bound
506     inline double dualBound() const {
507          return dualBound_;
508     }
509     void setDualBound(double value);
510     /// Infeasibility cost
511     inline double infeasibilityCost() const {
512          return infeasibilityCost_;
513     }
514     void setInfeasibilityCost(double value);
515     /** Amount of print out:
516         0 - none
517         1 - just final
518         2 - just factorizations
519         3 - as 2 plus a bit more
520         4 - verbose
521         above that 8,16,32 etc just for selective debug
522     */
523     /** Perturbation:
524         50  - switch on perturbation
525         100 - auto perturb if takes too long (1.0e-6 largest nonzero)
526         101 - we are perturbed
527         102 - don't try perturbing again
528         default is 100
529         others are for playing
530     */
531     inline int perturbation() const {
532          return perturbation_;
533     }
534     void setPerturbation(int value);
535     /// Current (or last) algorithm
536     inline int algorithm() const {
537          return algorithm_;
538     }
539     /// Set algorithm
540     inline void setAlgorithm(int value) {
541          algorithm_ = value;
542     }
543     /// Return true if the objective limit test can be relied upon
544     bool isObjectiveLimitTestValid() const ;
545     /// Sum of dual infeasibilities
546     inline double sumDualInfeasibilities() const {
547          return sumDualInfeasibilities_;
548     }
549     inline void setSumDualInfeasibilities(double value) {
550          sumDualInfeasibilities_ = value;
551     }
552     /// Sum of relaxed dual infeasibilities
553     inline double sumOfRelaxedDualInfeasibilities() const {
554          return sumOfRelaxedDualInfeasibilities_;
555     }
556     inline void setSumOfRelaxedDualInfeasibilities(double value) {
557          sumOfRelaxedDualInfeasibilities_ = value;
558     }
559     /// Number of dual infeasibilities
560     inline int numberDualInfeasibilities() const {
561          return numberDualInfeasibilities_;
562     }
563     inline void setNumberDualInfeasibilities(int value) {
564          numberDualInfeasibilities_ = value;
565     }
566     /// Number of dual infeasibilities (without free)
567     inline int numberDualInfeasibilitiesWithoutFree() const {
568          return numberDualInfeasibilitiesWithoutFree_;
569     }
570     /// Sum of primal infeasibilities
571     inline double sumPrimalInfeasibilities() const {
572          return sumPrimalInfeasibilities_;
573     }
574     inline void setSumPrimalInfeasibilities(double value) {
575          sumPrimalInfeasibilities_ = value;
576     }
577     /// Sum of relaxed primal infeasibilities
578     inline double sumOfRelaxedPrimalInfeasibilities() const {
579          return sumOfRelaxedPrimalInfeasibilities_;
580     }
581     inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
582          sumOfRelaxedPrimalInfeasibilities_ = value;
583     }
584     /// Number of primal infeasibilities
585     inline int numberPrimalInfeasibilities() const {
586          return numberPrimalInfeasibilities_;
587     }
588     inline void setNumberPrimalInfeasibilities(int value) {
589          numberPrimalInfeasibilities_ = value;
590     }
591     /** Save model to file, returns 0 if success.  This is designed for
592         use outside algorithms so does not save iterating arrays etc.
593     It does not save any messaging information.
594     Does not save scaling values.
595     It does not know about all types of virtual functions.
596     */
597     int saveModel(const char * fileName);
598     /** Restore model from file, returns 0 if success,
599         deletes current model */
600     int restoreModel(const char * fileName);
601
602     /** Just check solution (for external use) - sets sum of
603         infeasibilities etc.
604         If setToBounds 0 then primal column values not changed
605         and used to compute primal row activity values.  If 1 or 2
606         then status used - so all nonbasic variables set to
607         indicated bound and if any values changed (or ==2)  basic values re-computed.
608     */
609     void checkSolution(int setToBounds = 0);
610     /** Just check solution (for internal use) - sets sum of
611         infeasibilities etc. */
612     void checkSolutionInternal();
613     /// Useful row length arrays (0,1,2,3,4,5)
614     inline CoinIndexedVector * rowArray(int index) const {
615          return rowArray_[index];
616     }
617     /// Useful column length arrays (0,1,2,3,4,5)
618     inline CoinIndexedVector * columnArray(int index) const {
619          return columnArray_[index];
620     }
621     //@}
622
623     /******************** End of most useful part **************/
624     /**@name Functions less likely to be useful to casual user */
625     //@{
626     /** Given an existing factorization computes and checks
627         primal and dual solutions.  Uses input arrays for variables at
628         bounds.  Returns feasibility states */
629     int getSolution (  const double * rowActivities,
630                        const double * columnActivities);
631     /** Given an existing factorization computes and checks
632         primal and dual solutions.  Uses current problem arrays for
633         bounds.  Returns feasibility states */
634     int getSolution ();
635     /** Constructs a non linear cost from list of non-linearities (columns only)
636         First lower of each column is taken as real lower
637         Last lower is taken as real upper and cost ignored
638
639         Returns nonzero if bad data e.g. lowers not monotonic
640     */
641     int createPiecewiseLinearCosts(const int * starts,
642                                    const double * lower, const double * gradient);
643     /// dual row pivot choice
644     inline ClpDualRowPivot * dualRowPivot() const {
645          return dualRowPivot_;
646     }
647     /// primal column pivot choice
648     inline ClpPrimalColumnPivot * primalColumnPivot() const {
649          return primalColumnPivot_;
650     }
651     /// Returns true if model looks OK
652     inline bool goodAccuracy() const {
653          return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
654     }
655     /** Return model - updates any scalars */
656     void returnModel(ClpSimplex & otherModel);
657     /** Factorizes using current basis.
658         solveType - 1 iterating, 0 initial, -1 external
659         If 10 added then in primal values pass
660         Return codes are as from ClpFactorization unless initial factorization
661         when total number of singularities is returned.
662         Special case is numberRows_+1 -> all slack basis.
663     */
664     int internalFactorize(int solveType);
665     /// Save data
666     ClpDataSave saveData() ;
667     /// Restore data
668     void restoreData(ClpDataSave saved);
669     /// Clean up status
670     void cleanStatus();
671     /// Factorizes using current basis. For external use
672     int factorize();
673     /** Computes duals from scratch. If givenDjs then
674         allows for nonzero basic djs */
675     void computeDuals(double * givenDjs);
676     /// Computes primals from scratch
677     void computePrimals (  const double * rowActivities,
678                            const double * columnActivities);
679     /** Adds multiple of a column into an array */
680     void add(double * array,
681              int column, double multiplier) const;
682     /**
683        Unpacks one column of the matrix into indexed array
684        Uses sequenceIn_
685        Also applies scaling if needed
686     */
687     void unpack(CoinIndexedVector * rowArray) const ;
688     /**
689        Unpacks one column of the matrix into indexed array
690        Slack if sequence>= numberColumns
691        Also applies scaling if needed
692     */
693     void unpack(CoinIndexedVector * rowArray, int sequence) const;
694     /**
695        Unpacks one column of the matrix into indexed array
696        ** as packed vector
697        Uses sequenceIn_
698        Also applies scaling if needed
699     */
700     void unpackPacked(CoinIndexedVector * rowArray) ;
701     /**
702        Unpacks one column of the matrix into indexed array
703        ** as packed vector
704        Slack if sequence>= numberColumns
705        Also applies scaling if needed
706     */
707     void unpackPacked(CoinIndexedVector * rowArray, int sequence);
708protected:
709     /**
710         This does basis housekeeping and does values for in/out variables.
711         Can also decide to re-factorize
712     */
713     int housekeeping(double objectiveChange);
714     /** This sets largest infeasibility and most infeasible and sum
715         and number of infeasibilities (Primal) */
716     void checkPrimalSolution(const double * rowActivities = NULL,
717                              const double * columnActivies = NULL);
718     /** This sets largest infeasibility and most infeasible and sum
719         and number of infeasibilities (Dual) */
720     void checkDualSolution();
721     /** This sets sum and number of infeasibilities (Dual and Primal) */
722     void checkBothSolutions();
723     /**  If input negative scales objective so maximum <= -value
724          and returns scale factor used.  If positive unscales and also
725          redoes dual stuff
726     */
727     double scaleObjective(double value);
728     /// Solve using Dantzig-Wolfe decomposition and maybe in parallel
729     int solveDW(CoinStructuredModel * model);
730     /// Solve using Benders decomposition and maybe in parallel
731     int solveBenders(CoinStructuredModel * model);
732public:
733     /** For advanced use.  When doing iterative solves things can get
734         nasty so on values pass if incoming solution has largest
735         infeasibility < incomingInfeasibility throw out variables
736         from basis until largest infeasibility < allowedInfeasibility
737         or incoming largest infeasibility.
738         If allowedInfeasibility>= incomingInfeasibility this is
739         always possible altough you may end up with an all slack basis.
740
741         Defaults are 1.0,10.0
742     */
743     void setValuesPassAction(double incomingInfeasibility,
744                              double allowedInfeasibility);
745     //@}
746     /**@name most useful gets and sets */
747     //@{
748public:
749     /// Initial value for alpha accuracy calculation (-1.0 off)
750     inline double alphaAccuracy() const {
751          return alphaAccuracy_;
752     }
753     inline void setAlphaAccuracy(double value) {
754          alphaAccuracy_ = value;
755     }
756public:
757     /// Objective value
758     //inline double objectiveValue() const {
759     //return (objectiveValue_-bestPossibleImprovement_)*optimizationDirection_ - dblParam_[ClpObjOffset];
760     //}
761     /// Set disaster handler
762     inline void setDisasterHandler(ClpDisasterHandler * handler) {
763          disasterArea_ = handler;
764     }
765     /// Get disaster handler
766     inline ClpDisasterHandler * disasterHandler() const {
767          return disasterArea_;
768     }
769     /// Large bound value (for complementarity etc)
770     inline double largeValue() const {
771          return largeValue_;
772     }
773     void setLargeValue( double value) ;
774     /// Largest error on Ax-b
775     inline double largestPrimalError() const {
776          return largestPrimalError_;
777     }
778     /// Largest error on basic duals
779     inline double largestDualError() const {
780          return largestDualError_;
781     }
782     /// Largest error on Ax-b
783     inline void setLargestPrimalError(double value) {
784          largestPrimalError_ = value;
785     }
786     /// Largest error on basic duals
787     inline void setLargestDualError(double value) {
788          largestDualError_ = value;
789     }
790     /// Get zero tolerance
791     inline double zeroTolerance() const {
792          return zeroTolerance_;/*factorization_->zeroTolerance();*/
793     }
794     /// Set zero tolerance
795     inline void setZeroTolerance( double value) {
796          zeroTolerance_ = value;
797     }
798     /// Basic variables pivoting on which rows
799     inline int * pivotVariable() const {
800          return pivotVariable_;
801     }
802     /// If automatic scaling on
803     inline bool automaticScaling() const {
804          return automaticScale_ != 0;
805     }
806     inline void setAutomaticScaling(bool onOff) {
807          automaticScale_ = onOff ? 1 : 0;
808     }
809     /// Current dual tolerance
810     inline double currentDualTolerance() const {
811          return dualTolerance_;
812     }
813     inline void setCurrentDualTolerance(double value) {
814          dualTolerance_ = value;
815     }
816     /// Current primal tolerance
817     inline double currentPrimalTolerance() const {
818          return primalTolerance_;
819     }
820     inline void setCurrentPrimalTolerance(double value) {
821          primalTolerance_ = value;
822     }
823     /// How many iterative refinements to do
824     inline int numberRefinements() const {
825          return numberRefinements_;
826     }
827     void setNumberRefinements( int value) ;
828     /// Alpha (pivot element) for use by classes e.g. steepestedge
829     inline double alpha() const {
830          return alpha_;
831     }
832     inline void setAlpha(double value) {
833          alpha_ = value;
834     }
835     /// Reduced cost of last incoming for use by classes e.g. steepestedge
836     inline double dualIn() const {
837          return dualIn_;
838     }
839     /// Pivot Row for use by classes e.g. steepestedge
840     inline int pivotRow() const {
841          return pivotRow_;
842     }
843     inline void setPivotRow(int value) {
844          pivotRow_ = value;
845     }
846     /// value of incoming variable (in Dual)
847     double valueIncomingDual() const;
848     //@}
849
850protected:
851     /**@name protected methods */
852     //@{
853     /** May change basis and then returns number changed.
854         Computation of solutions may be overriden by given pi and solution
855     */
856     int gutsOfSolution ( double * givenDuals,
857                          const double * givenPrimals,
858                          bool valuesPass = false);
859     /// Does most of deletion (0 = all, 1 = most, 2 most + factorization)
860     void gutsOfDelete(int type);
861     /// Does most of copying
862     void gutsOfCopy(const ClpSimplex & rhs);
863     /** puts in format I like (rowLower,rowUpper) also see StandardMatrix
864         1 bit does rows (now and columns), (2 bit does column bounds), 4 bit does objective(s).
865         8 bit does solution scaling in
866         16 bit does rowArray and columnArray indexed vectors
867         and makes row copy if wanted, also sets columnStart_ etc
868         Also creates scaling arrays if needed.  It does scaling if needed.
869         16 also moves solutions etc in to work arrays
870         On 16 returns false if problem "bad" i.e. matrix or bounds bad
871         If startFinishOptions is -1 then called by user in getSolution
872         so do arrays but keep pivotVariable_
873     */
874     bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
875     /// Does rows and columns
876     void createRim1(bool initial);
877     /// Does objective
878     void createRim4(bool initial);
879     /// Does rows and columns and objective
880     void createRim5(bool initial);
881     /** releases above arrays and does solution scaling out.  May also
882         get rid of factorization data -
883         0 get rid of nothing, 1 get rid of arrays, 2 also factorization
884     */
885     void deleteRim(int getRidOfFactorizationData = 2);
886     /// Sanity check on input rim data (after scaling) - returns true if okay
887     bool sanityCheck();
888     //@}
889public:
890     /**@name public methods */
891     //@{
892     /** Return row or column sections - not as much needed as it
893         once was.  These just map into single arrays */
894     inline double * solutionRegion(int section) const {
895          if (!section) return rowActivityWork_;
896          else return columnActivityWork_;
897     }
898     inline double * djRegion(int section) const {
899          if (!section) return rowReducedCost_;
900          else return reducedCostWork_;
901     }
902     inline double * lowerRegion(int section) const {
903          if (!section) return rowLowerWork_;
904          else return columnLowerWork_;
905     }
906     inline double * upperRegion(int section) const {
907          if (!section) return rowUpperWork_;
908          else return columnUpperWork_;
909     }
910     inline double * costRegion(int section) const {
911          if (!section) return rowObjectiveWork_;
912          else return objectiveWork_;
913     }
914     /// Return region as single array
915     inline double * solutionRegion() const {
916          return solution_;
917     }
918     inline double * djRegion() const {
919          return dj_;
920     }
921     inline double * lowerRegion() const {
922          return lower_;
923     }
924     inline double * upperRegion() const {
925          return upper_;
926     }
927     inline double * costRegion() const {
928          return cost_;
929     }
930     inline Status getStatus(int sequence) const {
931          return static_cast<Status> (status_[sequence] & 7);
932     }
933     inline void setStatus(int sequence, Status newstatus) {
934          unsigned char & st_byte = status_[sequence];
935          st_byte = static_cast<unsigned char>(st_byte & ~7);
936          st_byte = static_cast<unsigned char>(st_byte | newstatus);
937     }
938     /// Start or reset using maximumRows_ and Columns_ - true if change
939     bool startPermanentArrays();
940     /** Normally the first factorization does sparse coding because
941         the factorization could be singular.  This allows initial dense
942         factorization when it is known to be safe
943     */
944     void setInitialDenseFactorization(bool onOff);
945     bool  initialDenseFactorization() const;
946     /** Return sequence In or Out */
947     inline int sequenceIn() const {
948          return sequenceIn_;
949     }
950     inline int sequenceOut() const {
951          return sequenceOut_;
952     }
953     /** Set sequenceIn or Out */
954     inline void  setSequenceIn(int sequence) {
955          sequenceIn_ = sequence;
956     }
957     inline void  setSequenceOut(int sequence) {
958          sequenceOut_ = sequence;
959     }
960     /** Return direction In or Out */
961     inline int directionIn() const {
962          return directionIn_;
963     }
964     inline int directionOut() const {
965          return directionOut_;
966     }
967     /** Set directionIn or Out */
968     inline void  setDirectionIn(int direction) {
969          directionIn_ = direction;
970     }
971     inline void  setDirectionOut(int direction) {
972          directionOut_ = direction;
973     }
974     /// Value of Out variable
975     inline double valueOut() const {
976          return valueOut_;
977     }
978     /// Set value of out variable
979     inline void setValueOut(double value) {
980          valueOut_=value;
981     }
982     /// Set lower of out variable
983     inline void setLowerOut(double value) {
984          lowerOut_=value;
985     }
986     /// Set upper of out variable
987     inline void setUpperOut(double value) {
988          upperOut_=value;
989     }
990     /// Set theta of out variable
991     inline void setTheta(double value) {
992          theta_=value;
993     }
994     /// Returns 1 if sequence indicates column
995     inline int isColumn(int sequence) const {
996          return sequence < numberColumns_ ? 1 : 0;
997     }
998     /// Returns sequence number within section
999     inline int sequenceWithin(int sequence) const {
1000          return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
1001     }
1002     /// Return row or column values
1003     inline double solution(int sequence) {
1004          return solution_[sequence];
1005     }
1006     /// Return address of row or column values
1007     inline double & solutionAddress(int sequence) {
1008          return solution_[sequence];
1009     }
1010     inline double reducedCost(int sequence) {
1011          return dj_[sequence];
1012     }
1013     inline double & reducedCostAddress(int sequence) {
1014          return dj_[sequence];
1015     }
1016     inline double lower(int sequence) {
1017          return lower_[sequence];
1018     }
1019     /// Return address of row or column lower bound
1020     inline double & lowerAddress(int sequence) {
1021          return lower_[sequence];
1022     }
1023     inline double upper(int sequence) {
1024          return upper_[sequence];
1025     }
1026     /// Return address of row or column upper bound
1027     inline double & upperAddress(int sequence) {
1028          return upper_[sequence];
1029     }
1030     inline double cost(int sequence) {
1031          return cost_[sequence];
1032     }
1033     /// Return address of row or column cost
1034     inline double & costAddress(int sequence) {
1035          return cost_[sequence];
1036     }
1037     /// Return original lower bound
1038     inline double originalLower(int iSequence) const {
1039          if (iSequence < numberColumns_) return columnLower_[iSequence];
1040          else
1041               return rowLower_[iSequence-numberColumns_];
1042     }
1043     /// Return original lower bound
1044     inline double originalUpper(int iSequence) const {
1045          if (iSequence < numberColumns_) return columnUpper_[iSequence];
1046          else
1047               return rowUpper_[iSequence-numberColumns_];
1048     }
1049     /// Theta (pivot change)
1050     inline double theta() const {
1051          return theta_;
1052     }
1053     /** Best possible improvement using djs (primal) or
1054         obj change by flipping bounds to make dual feasible (dual) */
1055     inline double bestPossibleImprovement() const {
1056          return bestPossibleImprovement_;
1057     }
1058     /// Return pointer to details of costs
1059     inline ClpNonLinearCost * nonLinearCost() const {
1060          return nonLinearCost_;
1061     }
1062     /** Return more special options
1063         1 bit - if presolve says infeasible in ClpSolve return
1064         2 bit - if presolved problem infeasible return
1065         4 bit - keep arrays like upper_ around
1066         8 bit - if factorization kept can still declare optimal at once
1067         16 bit - if checking replaceColumn accuracy before updating
1068         32 bit - say optimal if primal feasible!
1069         64 bit - give up easily in dual (and say infeasible)
1070         128 bit - no objective, 0-1 and in B&B
1071         256 bit - in primal from dual or vice versa
1072         512 bit - alternative use of solveType_
1073     */
1074     inline int moreSpecialOptions() const {
1075          return moreSpecialOptions_;
1076     }
1077     /** Set more special options
1078         1 bit - if presolve says infeasible in ClpSolve return
1079         2 bit - if presolved problem infeasible return
1080         4 bit - keep arrays like upper_ around
1081         8 bit - no free or superBasic variables
1082         16 bit - if checking replaceColumn accuracy before updating
1083         32 bit - say optimal if primal feasible!
1084         64 bit - give up easily in dual (and say infeasible)
1085         128 bit - no objective, 0-1 and in B&B
1086         256 bit - in primal from dual or vice versa
1087         512 bit - alternative use of solveType_
1088     */
1089     inline void setMoreSpecialOptions(int value) {
1090          moreSpecialOptions_ = value;
1091     }
1092     //@}
1093     /**@name status methods */
1094     //@{
1095     inline void setFakeBound(int sequence, FakeBound fakeBound) {
1096          unsigned char & st_byte = status_[sequence];
1097          st_byte = static_cast<unsigned char>(st_byte & ~24);
1098          st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
1099     }
1100     inline FakeBound getFakeBound(int sequence) const {
1101          return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
1102     }
1103     inline void setRowStatus(int sequence, Status newstatus) {
1104          unsigned char & st_byte = status_[sequence+numberColumns_];
1105          st_byte = static_cast<unsigned char>(st_byte & ~7);
1106          st_byte = static_cast<unsigned char>(st_byte | newstatus);
1107     }
1108     inline Status getRowStatus(int sequence) const {
1109          return static_cast<Status> (status_[sequence+numberColumns_] & 7);
1110     }
1111     inline void setColumnStatus(int sequence, Status newstatus) {
1112          unsigned char & st_byte = status_[sequence];
1113          st_byte = static_cast<unsigned char>(st_byte & ~7);
1114          st_byte = static_cast<unsigned char>(st_byte | newstatus);
1115     }
1116     inline Status getColumnStatus(int sequence) const {
1117          return static_cast<Status> (status_[sequence] & 7);
1118     }
1119     inline void setPivoted( int sequence) {
1120          status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
1121     }
1122     inline void clearPivoted( int sequence) {
1123          status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
1124     }
1125     inline bool pivoted(int sequence) const {
1126          return (((status_[sequence] >> 5) & 1) != 0);
1127     }
1128     /// To flag a variable (not inline to allow for column generation)
1129     void setFlagged( int sequence);
1130     inline void clearFlagged( int sequence) {
1131          status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
1132     }
1133     inline bool flagged(int sequence) const {
1134          return ((status_[sequence] & 64) != 0);
1135     }
1136     /// To say row active in primal pivot row choice
1137     inline void setActive( int iRow) {
1138          status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
1139     }
1140     inline void clearActive( int iRow) {
1141          status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
1142     }
1143     inline bool active(int iRow) const {
1144          return ((status_[iRow] & 128) != 0);
1145     }
1146     /** Set up status array (can be used by OsiClp).
1147         Also can be used to set up all slack basis */
1148     void createStatus() ;
1149     /** Sets up all slack basis and resets solution to
1150         as it was after initial load or readMps */
1151     void allSlackBasis(bool resetSolution = false);
1152
1153     /// So we know when to be cautious
1154     inline int lastBadIteration() const {
1155          return lastBadIteration_;
1156     }
1157     /// Progress flag - at present 0 bit says artificials out
1158     inline int progressFlag() const {
1159          return (progressFlag_ & 3);
1160     }
1161     /// Force re-factorization early
1162     inline void forceFactorization(int value) {
1163          forceFactorization_ = value;
1164     }
1165     /// Raw objective value (so always minimize in primal)
1166     inline double rawObjectiveValue() const {
1167          return objectiveValue_;
1168     }
1169     /// Compute objective value from solution and put in objectiveValue_
1170     void computeObjectiveValue(bool useWorkingSolution = false);
1171     /// Compute minimization objective value from internal solution without perturbation
1172     double computeInternalObjectiveValue();
1173     /** Number of extra rows.  These are ones which will be dynamically created
1174         each iteration.  This is for GUB but may have other uses.
1175     */
1176     inline int numberExtraRows() const {
1177          return numberExtraRows_;
1178     }
1179     /** Maximum number of basic variables - can be more than number of rows if GUB
1180     */
1181     inline int maximumBasic() const {
1182          return maximumBasic_;
1183     }
1184     /// Iteration when we entered dual or primal
1185     inline int baseIteration() const {
1186          return baseIteration_;
1187     }
1188     /// Create C++ lines to get to current state
1189     void generateCpp( FILE * fp, bool defaultFactor = false);
1190     /// Gets clean and emptyish factorization
1191     ClpFactorization * getEmptyFactorization();
1192     /// May delete or may make clean and emptyish factorization
1193     void setEmptyFactorization();
1194     /// Move status and solution across
1195     void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
1196     //@}
1197
1198     ///@name Basis handling
1199     // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal)
1200     // *** At present only without scaling
1201     // *** Slacks havve -1.0 element (so == row activity) - take care
1202     ///Get a row of the tableau (slack part in slack if not NULL)
1203     void getBInvARow(int row, double* z, double * slack = NULL);
1204
1205     ///Get a row of the basis inverse
1206     void getBInvRow(int row, double* z);
1207
1208     ///Get a column of the tableau
1209     void getBInvACol(int col, double* vec);
1210
1211     ///Get a column of the basis inverse
1212     void getBInvCol(int col, double* vec);
1213
1214     /** Get basic indices (order of indices corresponds to the
1215         order of elements in a vector retured by getBInvACol() and
1216         getBInvCol()).
1217     */
1218     void getBasics(int* index);
1219
1220     //@}
1221     //-------------------------------------------------------------------------
1222     /**@name Changing bounds on variables and constraints */
1223     //@{
1224     /** Set an objective function coefficient */
1225     void setObjectiveCoefficient( int elementIndex, double elementValue );
1226     /** Set an objective function coefficient */
1227     inline void setObjCoeff( int elementIndex, double elementValue ) {
1228          setObjectiveCoefficient( elementIndex, elementValue);
1229     }
1230
1231     /** Set a single column lower bound<br>
1232         Use -DBL_MAX for -infinity. */
1233     void setColumnLower( int elementIndex, double elementValue );
1234
1235     /** Set a single column upper bound<br>
1236         Use DBL_MAX for infinity. */
1237     void setColumnUpper( int elementIndex, double elementValue );
1238
1239     /** Set a single column lower and upper bound */
1240     void setColumnBounds( int elementIndex,
1241                           double lower, double upper );
1242
1243     /** Set the bounds on a number of columns simultaneously<br>
1244         The default implementation just invokes setColLower() and
1245         setColUpper() over and over again.
1246         @param indexFirst,indexLast pointers to the beginning and after the
1247            end of the array of the indices of the variables whose
1248        <em>either</em> bound changes
1249         @param boundList the new lower/upper bound pairs for the variables
1250     */
1251     void setColumnSetBounds(const int* indexFirst,
1252                             const int* indexLast,
1253                             const double* boundList);
1254
1255     /** Set a single column lower bound<br>
1256         Use -DBL_MAX for -infinity. */
1257     inline void setColLower( int elementIndex, double elementValue ) {
1258          setColumnLower(elementIndex, elementValue);
1259     }
1260     /** Set a single column upper bound<br>
1261         Use DBL_MAX for infinity. */
1262     inline void setColUpper( int elementIndex, double elementValue ) {
1263          setColumnUpper(elementIndex, elementValue);
1264     }
1265
1266     /** Set a single column lower and upper bound */
1267     inline void setColBounds( int elementIndex,
1268                               double newlower, double newupper ) {
1269          setColumnBounds(elementIndex, newlower, newupper);
1270     }
1271
1272     /** Set the bounds on a number of columns simultaneously<br>
1273         @param indexFirst,indexLast pointers to the beginning and after the
1274            end of the array of the indices of the variables whose
1275        <em>either</em> bound changes
1276         @param boundList the new lower/upper bound pairs for the variables
1277     */
1278     inline void setColSetBounds(const int* indexFirst,
1279                                 const int* indexLast,
1280                                 const double* boundList) {
1281          setColumnSetBounds(indexFirst, indexLast, boundList);
1282     }
1283
1284     /** Set a single row lower bound<br>
1285         Use -DBL_MAX for -infinity. */
1286     void setRowLower( int elementIndex, double elementValue );
1287
1288     /** Set a single row upper bound<br>
1289         Use DBL_MAX for infinity. */
1290     void setRowUpper( int elementIndex, double elementValue ) ;
1291
1292     /** Set a single row lower and upper bound */
1293     void setRowBounds( int elementIndex,
1294                        double lower, double upper ) ;
1295
1296     /** Set the bounds on a number of rows simultaneously<br>
1297         @param indexFirst,indexLast pointers to the beginning and after the
1298            end of the array of the indices of the constraints whose
1299        <em>either</em> bound changes
1300         @param boundList the new lower/upper bound pairs for the constraints
1301     */
1302     void setRowSetBounds(const int* indexFirst,
1303                          const int* indexLast,
1304                          const double* boundList);
1305     /// Resizes rim part of model
1306     void resize (int newNumberRows, int newNumberColumns);
1307
1308     //@}
1309
1310////////////////// data //////////////////
1311protected:
1312
1313     /**@name data.  Many arrays have a row part and a column part.
1314      There is a single array with both - columns then rows and
1315      then normally two arrays pointing to rows and columns.  The
1316      single array is the owner of memory
1317     */
1318     //@{
1319     /** Best possible improvement using djs (primal) or
1320         obj change by flipping bounds to make dual feasible (dual) */
1321     double bestPossibleImprovement_;
1322     /// Zero tolerance
1323     double zeroTolerance_;
1324     /// Sequence of worst (-1 if feasible)
1325     int columnPrimalSequence_;
1326     /// Sequence of worst (-1 if feasible)
1327     int rowPrimalSequence_;
1328     /// "Best" objective value
1329     double bestObjectiveValue_;
1330     /// More special options - see set for details
1331     int moreSpecialOptions_;
1332     /// Iteration when we entered dual or primal
1333     int baseIteration_;
1334     /// Primal tolerance needed to make dual feasible (<largeTolerance)
1335     double primalToleranceToGetOptimal_;
1336     /// Large bound value (for complementarity etc)
1337     double largeValue_;
1338     /// Largest error on Ax-b
1339     double largestPrimalError_;
1340     /// Largest error on basic duals
1341     double largestDualError_;
1342     /// For computing whether to re-factorize
1343     double alphaAccuracy_;
1344     /// Dual bound
1345     double dualBound_;
1346     /// Alpha (pivot element)
1347     double alpha_;
1348     /// Theta (pivot change)
1349     double theta_;
1350     /// Lower Bound on In variable
1351     double lowerIn_;
1352     /// Value of In variable
1353     double valueIn_;
1354     /// Upper Bound on In variable
1355     double upperIn_;
1356     /// Reduced cost of In variable
1357     double dualIn_;
1358     /// Lower Bound on Out variable
1359     double lowerOut_;
1360     /// Value of Out variable
1361     double valueOut_;
1362     /// Upper Bound on Out variable
1363     double upperOut_;
1364     /// Infeasibility (dual) or ? (primal) of Out variable
1365     double dualOut_;
1366     /// Current dual tolerance for algorithm
1367     double dualTolerance_;
1368     /// Current primal tolerance for algorithm
1369     double primalTolerance_;
1370     /// Sum of dual infeasibilities
1371     double sumDualInfeasibilities_;
1372     /// Sum of primal infeasibilities
1373     double sumPrimalInfeasibilities_;
1374     /// Weight assigned to being infeasible in primal
1375     double infeasibilityCost_;
1376     /// Sum of Dual infeasibilities using tolerance based on error in duals
1377     double sumOfRelaxedDualInfeasibilities_;
1378     /// Sum of Primal infeasibilities using tolerance based on error in primals
1379     double sumOfRelaxedPrimalInfeasibilities_;
1380     /// Acceptable pivot value just after factorization
1381     double acceptablePivot_;
1382     /// Working copy of lower bounds (Owner of arrays below)
1383     double * lower_;
1384     /// Row lower bounds - working copy
1385     double * rowLowerWork_;
1386     /// Column lower bounds - working copy
1387     double * columnLowerWork_;
1388     /// Working copy of upper bounds (Owner of arrays below)
1389     double * upper_;
1390     /// Row upper bounds - working copy
1391     double * rowUpperWork_;
1392     /// Column upper bounds - working copy
1393     double * columnUpperWork_;
1394     /// Working copy of objective (Owner of arrays below)
1395     double * cost_;
1396     /// Row objective - working copy
1397     double * rowObjectiveWork_;
1398     /// Column objective - working copy
1399     double * objectiveWork_;
1400     /// Useful row length arrays
1401     CoinIndexedVector * rowArray_[6];
1402     /// Useful column length arrays
1403     CoinIndexedVector * columnArray_[6];
1404     /// Sequence of In variable
1405     int sequenceIn_;
1406     /// Direction of In, 1 going up, -1 going down, 0 not a clude
1407     int directionIn_;
1408     /// Sequence of Out variable
1409     int sequenceOut_;
1410     /// Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic
1411     int directionOut_;
1412     /// Pivot Row
1413     int pivotRow_;
1414     /// Last good iteration (immediately after a re-factorization)
1415     int lastGoodIteration_;
1416     /// Working copy of reduced costs (Owner of arrays below)
1417     double * dj_;
1418     /// Reduced costs of slacks not same as duals (or - duals)
1419     double * rowReducedCost_;
1420     /// Possible scaled reduced costs
1421     double * reducedCostWork_;
1422     /// Working copy of primal solution (Owner of arrays below)
1423     double * solution_;
1424     /// Row activities - working copy
1425     double * rowActivityWork_;
1426     /// Column activities - working copy
1427     double * columnActivityWork_;
1428     /// Number of dual infeasibilities
1429     int numberDualInfeasibilities_;
1430     /// Number of dual infeasibilities (without free)
1431     int numberDualInfeasibilitiesWithoutFree_;
1432     /// Number of primal infeasibilities
1433     int numberPrimalInfeasibilities_;
1434     /// How many iterative refinements to do
1435     int numberRefinements_;
1436     /// dual row pivot choice
1437     ClpDualRowPivot * dualRowPivot_;
1438     /// primal column pivot choice
1439     ClpPrimalColumnPivot * primalColumnPivot_;
1440     /// Basic variables pivoting on which rows
1441     int * pivotVariable_;
1442     /// factorization
1443     ClpFactorization * factorization_;
1444     /// Saved version of solution
1445     double * savedSolution_;
1446     /// Number of times code has tentatively thought optimal
1447     int numberTimesOptimal_;
1448     /// Disaster handler
1449     ClpDisasterHandler * disasterArea_;
1450     /// If change has been made (first attempt at stopping looping)
1451     int changeMade_;
1452     /// Algorithm >0 == Primal, <0 == Dual
1453     int algorithm_;
1454     /** Now for some reliability aids
1455         This forces re-factorization early */
1456     int forceFactorization_;
1457     /** Perturbation:
1458         -50 to +50 - perturb by this power of ten (-6 sounds good)
1459         100 - auto perturb if takes too long (1.0e-6 largest nonzero)
1460         101 - we are perturbed
1461         102 - don't try perturbing again
1462         default is 100
1463     */
1464     int perturbation_;
1465     /// Saved status regions
1466     unsigned char * saveStatus_;
1467     /** Very wasteful way of dealing with infeasibilities in primal.
1468         However it will allow non-linearities and use of dual
1469         analysis.  If it doesn't work it can easily be replaced.
1470     */
1471     ClpNonLinearCost * nonLinearCost_;
1472     /// So we know when to be cautious
1473     int lastBadIteration_;
1474     /// So we know when to open up again
1475     int lastFlaggedIteration_;
1476     /// Can be used for count of fake bounds (dual) or fake costs (primal)
1477     int numberFake_;
1478     /// Can be used for count of changed costs (dual) or changed bounds (primal)
1479     int numberChanged_;
1480     /// Progress flag - at present 0 bit says artificials out, 1 free in
1481     int progressFlag_;
1482     /// First free/super-basic variable (-1 if none)
1483     int firstFree_;
1484     /** Number of extra rows.  These are ones which will be dynamically created
1485         each iteration.  This is for GUB but may have other uses.
1486     */
1487     int numberExtraRows_;
1488     /** Maximum number of basic variables - can be more than number of rows if GUB
1489     */
1490     int maximumBasic_;
1491     /// If may skip final factorize then allow up to this pivots (default 20)
1492     int dontFactorizePivots_;
1493     /** For advanced use.  When doing iterative solves things can get
1494         nasty so on values pass if incoming solution has largest
1495         infeasibility < incomingInfeasibility throw out variables
1496         from basis until largest infeasibility < allowedInfeasibility.
1497         if allowedInfeasibility>= incomingInfeasibility this is
1498         always possible altough you may end up with an all slack basis.
1499
1500         Defaults are 1.0,10.0
1501     */
1502     double incomingInfeasibility_;
1503     double allowedInfeasibility_;
1504     /// Automatic scaling of objective and rhs and bounds
1505     int automaticScale_;
1506     /// Maximum perturbation array size (take out when code rewritten)
1507     int maximumPerturbationSize_;
1508     /// Perturbation array (maximumPerturbationSize_)
1509     double * perturbationArray_;
1510     /// A copy of model with certain state - normally without cuts
1511     ClpSimplex * baseModel_;
1512     /// For dealing with all issues of cycling etc
1513     ClpSimplexProgress progress_;
1514public:
1515     /// Spare int array for passing information [0]!=0 switches on
1516     mutable int spareIntArray_[4];
1517     /// Spare double array for passing information [0]!=0 switches on
1518     mutable double spareDoubleArray_[4];
1519protected:
1520     /// Allow OsiClp certain perks
1521     friend class OsiClpSolverInterface;
1522     //@}
1523};
1524//#############################################################################
1525/** A function that tests the methods in the ClpSimplex class. The
1526    only reason for it not to be a member method is that this way it doesn't
1527    have to be compiled into the library. And that's a gain, because the
1528    library should be compiled with optimization on, but this method should be
1529    compiled with debugging.
1530
1531    It also does some testing of ClpFactorization class
1532 */
1533void
1534ClpSimplexUnitTest(const std::string & mpsDir);
1535
1536// For Devex stuff
1537#define DEVEX_TRY_NORM 1.0e-4
1538#define DEVEX_ADD_ONE 1.0
1539#endif
Note: See TracBrowser for help on using the repository browser.