Clp 1.17.5
Loading...
Searching...
No Matches
ClpInterior.hpp
Go to the documentation of this file.
1/* $Id: ClpInterior.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
2// Copyright (C) 2003, International Business Machines
3// Corporation and others. All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5/*
6 Authors
7
8 John Tomlin (pdco)
9 John Forrest (standard predictor-corrector)
10
11 Note JJF has added arrays - this takes more memory but makes
12 flow easier to understand and hopefully easier to extend
13
14 */
15#ifndef ClpInterior_H
16#define ClpInterior_H
17
18#include <iostream>
19#include <cfloat>
20#include "ClpModel.hpp"
21#include "ClpMatrixBase.hpp"
22#include "ClpSolve.hpp"
23#include "CoinDenseVector.hpp"
24class ClpLsqr;
25class ClpPdcoBase;
27typedef struct {
28 double atolmin;
29 double r3norm;
30 double LSdamp;
31 double *deltay;
32} Info;
34
35typedef struct {
36 double atolold;
37 double atolnew;
38 double r3ratio;
39 int istop;
40 int itncg;
41} Outfo;
43
44typedef struct {
45 double gamma;
46 double delta;
48 double FeaTol;
49 double OptTol;
50 double StepTol;
51 double x0min;
52 double z0min;
53 double mu0;
54 int LSmethod; // 1=Cholesky 2=QR 3=LSQR
55 int LSproblem; // See below
57 double LSQRatol1; // Initial atol
58 double LSQRatol2; // Smallest atol (unless atol1 is smaller)
59 double LSQRconlim;
60 int wait;
61} Options;
62class Lsqr;
63class ClpCholeskyBase;
64// ***** END
72class ClpInterior : public ClpModel {
73 friend void ClpInteriorUnitTest(const std::string &mpsDir,
74 const std::string &netlibDir);
75
76public:
81
90 ClpInterior(const ClpModel *wholeModel,
91 int numberRows, const int *whichRows,
92 int numberColumns, const int *whichColumns,
93 bool dropNames = true, bool dropIntegers = true);
98 // Ones below are just ClpModel with some changes
111 const double *collb, const double *colub,
112 const double *obj,
113 const double *rowlb, const double *rowub,
114 const double *rowObjective = NULL);
115 void loadProblem(const CoinPackedMatrix &matrix,
116 const double *collb, const double *colub,
117 const double *obj,
118 const double *rowlb, const double *rowub,
119 const double *rowObjective = NULL);
120
123 void loadProblem(const int numcols, const int numrows,
124 const CoinBigIndex *start, const int *index,
125 const double *value,
126 const double *collb, const double *colub,
127 const double *obj,
128 const double *rowlb, const double *rowub,
129 const double *rowObjective = NULL);
131 void loadProblem(const int numcols, const int numrows,
132 const CoinBigIndex *start, const int *index,
133 const double *value, const int *length,
134 const double *collb, const double *colub,
135 const double *obj,
136 const double *rowlb, const double *rowub,
137 const double *rowObjective = NULL);
139 int readMps(const char *filename,
140 bool keepNames = false,
141 bool ignoreErrors = false);
146 void borrowModel(ClpModel &otherModel);
148 void returnModel(ClpModel &otherModel);
150
154 int pdco();
155 // ** Temporary version
156 int pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo);
160
164 inline bool primalFeasible() const
165 {
166 return (sumPrimalInfeasibilities_ <= 1.0e-5);
167 }
169 inline bool dualFeasible() const
170 {
171 return (sumDualInfeasibilities_ <= 1.0e-5);
172 }
174 inline int algorithm() const
175 {
176 return algorithm_;
177 }
179 inline void setAlgorithm(int value)
180 {
181 algorithm_ = value;
182 }
184 inline CoinWorkDouble sumDualInfeasibilities() const
185 {
187 }
189 inline CoinWorkDouble sumPrimalInfeasibilities() const
190 {
192 }
194 inline CoinWorkDouble dualObjective() const
195 {
196 return dualObjective_;
197 }
199 inline CoinWorkDouble primalObjective() const
200 {
201 return primalObjective_;
202 }
204 inline CoinWorkDouble diagonalNorm() const
205 {
206 return diagonalNorm_;
207 }
209 inline CoinWorkDouble linearPerturbation() const
210 {
211 return linearPerturbation_;
212 }
213 inline void setLinearPerturbation(CoinWorkDouble value)
214 {
215 linearPerturbation_ = value;
216 }
218 inline CoinWorkDouble projectionTolerance() const
219 {
221 }
222 inline void setProjectionTolerance(CoinWorkDouble value)
223 {
224 projectionTolerance_ = value;
225 }
227 inline CoinWorkDouble diagonalPerturbation() const
228 {
230 }
231 inline void setDiagonalPerturbation(CoinWorkDouble value)
232 {
233 diagonalPerturbation_ = value;
234 }
236 inline CoinWorkDouble gamma() const
237 {
238 return gamma_;
239 }
240 inline void setGamma(CoinWorkDouble value)
241 {
242 gamma_ = value;
243 }
245 inline CoinWorkDouble delta() const
246 {
247 return delta_;
248 }
249 inline void setDelta(CoinWorkDouble value)
250 {
251 delta_ = value;
252 }
254 inline CoinWorkDouble complementarityGap() const
255 {
256 return complementarityGap_;
257 }
259
263 inline CoinWorkDouble largestPrimalError() const
264 {
265 return largestPrimalError_;
266 }
268 inline CoinWorkDouble largestDualError() const
269 {
270 return largestDualError_;
271 }
273 inline int maximumBarrierIterations() const
274 {
276 }
277 inline void setMaximumBarrierIterations(int value)
278 {
280 }
284 int numberFixed() const;
287 void fixFixed(bool reallyFix = true);
289 inline CoinWorkDouble *primalR() const
290 {
291 return primalR_;
292 }
294 inline CoinWorkDouble *dualR() const
295 {
296 return dualR_;
297 }
299
300protected:
306 void gutsOfCopy(const ClpInterior &rhs);
315public:
319 inline CoinWorkDouble rawObjectiveValue() const
320 {
321 return objectiveValue_;
322 }
324 inline int isColumn(int sequence) const
325 {
326 return sequence < numberColumns_ ? 1 : 0;
327 }
329 inline int sequenceWithin(int sequence) const
330 {
331 return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
332 }
337 CoinWorkDouble quadraticDjs(CoinWorkDouble *djRegion, const CoinWorkDouble *solution,
338 CoinWorkDouble scaleFactor);
339
341 inline void setFixed(int sequence)
342 {
343 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 1);
344 }
345 inline void clearFixed(int sequence)
346 {
347 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~1);
348 }
349 inline bool fixed(int sequence) const
350 {
351 return ((status_[sequence] & 1) != 0);
352 }
353
355 inline void setFlagged(int sequence)
356 {
357 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 2);
358 }
359 inline void clearFlagged(int sequence)
360 {
361 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~2);
362 }
363 inline bool flagged(int sequence) const
364 {
365 return ((status_[sequence] & 2) != 0);
366 }
367
369 inline void setFixedOrFree(int sequence)
370 {
371 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 4);
372 }
373 inline void clearFixedOrFree(int sequence)
374 {
375 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~4);
376 }
377 inline bool fixedOrFree(int sequence) const
378 {
379 return ((status_[sequence] & 4) != 0);
380 }
381
383 inline void setLowerBound(int sequence)
384 {
385 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 8);
386 }
387 inline void clearLowerBound(int sequence)
388 {
389 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~8);
390 }
391 inline bool lowerBound(int sequence) const
392 {
393 return ((status_[sequence] & 8) != 0);
394 }
395
397 inline void setUpperBound(int sequence)
398 {
399 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 16);
400 }
401 inline void clearUpperBound(int sequence)
402 {
403 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~16);
404 }
405 inline bool upperBound(int sequence) const
406 {
407 return ((status_[sequence] & 16) != 0);
408 }
409
411 inline void setFakeLower(int sequence)
412 {
413 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 32);
414 }
415 inline void clearFakeLower(int sequence)
416 {
417 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~32);
418 }
419 inline bool fakeLower(int sequence) const
420 {
421 return ((status_[sequence] & 32) != 0);
422 }
423
425 inline void setFakeUpper(int sequence)
426 {
427 status_[sequence] = static_cast< unsigned char >(status_[sequence] | 64);
428 }
429 inline void clearFakeUpper(int sequence)
430 {
431 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~64);
432 }
433 inline bool fakeUpper(int sequence) const
434 {
435 return ((status_[sequence] & 64) != 0);
436 }
438
440protected:
448 CoinWorkDouble largestPrimalError_;
450 CoinWorkDouble largestDualError_;
456 CoinWorkDouble worstComplementarity_;
458public:
459 CoinWorkDouble xsize_;
460 CoinWorkDouble zsize_;
461
462protected:
464 CoinWorkDouble *lower_;
466 CoinWorkDouble *rowLowerWork_;
468 CoinWorkDouble *columnLowerWork_;
470 CoinWorkDouble *upper_;
472 CoinWorkDouble *rowUpperWork_;
474 CoinWorkDouble *columnUpperWork_;
476 CoinWorkDouble *cost_;
477
478public:
480 CoinWorkDouble *rhs_;
481 CoinWorkDouble *x_;
482 CoinWorkDouble *y_;
483 CoinWorkDouble *dj_;
484
485protected:
492 CoinWorkDouble mu_;
494 CoinWorkDouble objectiveNorm_;
496 CoinWorkDouble rhsNorm_;
498 CoinWorkDouble solutionNorm_;
500 CoinWorkDouble dualObjective_;
502 CoinWorkDouble primalObjective_;
504 CoinWorkDouble diagonalNorm_;
506 CoinWorkDouble stepLength_;
508 CoinWorkDouble linearPerturbation_;
510 CoinWorkDouble diagonalPerturbation_;
511 // gamma from Saunders and Tomlin regularized
512 CoinWorkDouble gamma_;
513 // delta from Saunders and Tomlin regularized
514 CoinWorkDouble delta_;
516 CoinWorkDouble targetGap_;
518 CoinWorkDouble projectionTolerance_;
520 CoinWorkDouble maximumRHSError_;
524 CoinWorkDouble maximumDualError_;
526 CoinWorkDouble diagonalScaleFactor_;
528 CoinWorkDouble scaleFactor_;
530 CoinWorkDouble actualPrimalStep_;
532 CoinWorkDouble actualDualStep_;
536#define LENGTH_HISTORY 5
539 CoinWorkDouble complementarityGap_;
541 CoinWorkDouble baseObjectiveNorm_;
545 CoinWorkDouble maximumRHSChange_;
547 CoinWorkDouble *errorRegion_;
549 CoinWorkDouble *rhsFixRegion_;
551 CoinWorkDouble *upperSlack_;
553 CoinWorkDouble *lowerSlack_;
555 CoinWorkDouble *diagonal_;
557 CoinWorkDouble *solution_;
559 CoinWorkDouble *workArray_;
561 CoinWorkDouble *deltaX_;
563 CoinWorkDouble *deltaY_;
565 CoinWorkDouble *deltaZ_;
567 CoinWorkDouble *deltaW_;
569 CoinWorkDouble *deltaSU_;
570 CoinWorkDouble *deltaSL_;
572 CoinWorkDouble *primalR_;
574 CoinWorkDouble *dualR_;
576 CoinWorkDouble *rhsB_;
578 CoinWorkDouble *rhsU_;
580 CoinWorkDouble *rhsL_;
582 CoinWorkDouble *rhsZ_;
584 CoinWorkDouble *rhsW_;
586 CoinWorkDouble *rhsC_;
588 CoinWorkDouble *zVec_;
590 CoinWorkDouble *wVec_;
606};
607//#############################################################################
616void ClpInteriorUnitTest(const std::string &mpsDir,
617 const std::string &netlibDir);
618
619#endif
620
621/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
622*/
void ClpInteriorUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the ClpInterior class.
#define LENGTH_HISTORY
historyInfeasibility.
Base class for Clp Cholesky factorization Will do better factorization.
This solves LPs using interior point methods.
CoinWorkDouble diagonalPerturbation_
diagonalPerturbation
CoinWorkDouble mu_
Below here is standard barrier stuff mu.
void setDiagonalPerturbation(CoinWorkDouble value)
friend void ClpInteriorUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the ClpInterior class.
CoinWorkDouble dualObjective() const
dualObjective.
bool goneDualFeasible_
goneDualFeasible.
int pdco()
Pdco algorithm - see ClpPdco.hpp for method.
void setGamma(CoinWorkDouble value)
CoinWorkDouble * deltaY_
delta Y
void loadProblem(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub, const double *rowObjective=NULL)
Just like the other loadProblem() method except that the matrix is given in a standard column major o...
int readMps(const char *filename, bool keepNames=false, bool ignoreErrors=false)
Read an mps file from the given filename.
void loadProblem(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const int *length, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub, const double *rowObjective=NULL)
This one is for after presolve to save memory.
void borrowModel(ClpModel &otherModel)
Borrow model.
CoinWorkDouble * primalR_
Primal regularization array.
CoinWorkDouble * zVec_
zVec
CoinWorkDouble maximumRHSError_
maximumRHSError. maximum Ax
CoinWorkDouble projectionTolerance_
projectionTolerance
CoinWorkDouble largestDualError() const
Largest error on basic duals.
void setMaximumBarrierIterations(int value)
CoinWorkDouble primalObjective_
primalObjective.
void setFixedOrFree(int sequence)
To say a variable is fixed OR free.
CoinWorkDouble complementarityGap_
complementarityGap.
bool sanityCheck()
Sanity check on input rim data.
bool fixed(int sequence) const
CoinWorkDouble diagonalPerturbation() const
diagonalPerturbation
CoinWorkDouble * rowUpperWork_
Row upper bounds - working copy.
CoinWorkDouble diagonalScaleFactor_
diagonalScaleFactor.
CoinWorkDouble largestPrimalError() const
Largest error on Ax-b.
CoinWorkDouble targetGap_
targetGap
void clearFakeUpper(int sequence)
CoinWorkDouble * deltaX_
delta X
CoinWorkDouble * y_
CoinWorkDouble rawObjectiveValue() const
Raw objective value (so always minimize)
bool upperBound(int sequence) const
void clearFixedOrFree(int sequence)
CoinWorkDouble stepLength_
stepLength
CoinWorkDouble * columnLowerWork_
Column lower bounds - working copy.
int numberFixed() const
Return number fixed to see if worth presolving.
~ClpInterior()
Destructor.
void setFlagged(int sequence)
To flag a variable.
bool createWorkingData()
Returns true if data looks okay, false if not.
CoinWorkDouble * lower_
Working copy of lower bounds (Owner of arrays below)
bool flagged(int sequence) const
bool gonePrimalFeasible_
gonePrimalFeasible.
CoinWorkDouble * rhsB_
rhs B
bool fixedOrFree(int sequence) const
ClpCholeskyBase * cholesky_
cholesky.
CoinWorkDouble * primalR() const
Primal erturbation vector.
CoinWorkDouble xsize_
CoinWorkDouble sumDualInfeasibilities() const
Sum of dual infeasibilities.
CoinWorkDouble worstDirectionAccuracy_
worstDirectionAccuracy
void fixFixed(bool reallyFix=true)
fix variables interior says should be.
CoinWorkDouble * rhs_
Rhs.
int maximumBarrierIterations_
Maximum iterations.
CoinWorkDouble * x_
CoinWorkDouble * errorRegion_
errorRegion. i.e. Ax
CoinWorkDouble * rhsL_
rhsL.
CoinWorkDouble sumPrimalInfeasibilities_
Sum of primal infeasibilities.
CoinWorkDouble * rhsW_
rhsW.
CoinWorkDouble zsize_
CoinWorkDouble scaleFactor_
scaleFactor. For scaling objective
CoinWorkDouble * lowerSlack_
lowerSlack
void loadProblem(const ClpMatrixBase &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub, const double *rowObjective=NULL)
Loads a problem (the constraints on the rows are given by lower and upper bounds).
CoinWorkDouble * rhsFixRegion_
rhsFixRegion.
bool fakeLower(int sequence) const
CoinWorkDouble * dualR() const
Dual erturbation vector.
CoinWorkDouble * upper_
Working copy of upper bounds (Owner of arrays below)
CoinWorkDouble linearPerturbation_
linearPerturbation
CoinWorkDouble worstComplementarity_
Worst complementarity.
bool lowerBound(int sequence) const
void gutsOfDelete()
Does most of deletion.
ClpInterior(const ClpModel &)
Copy constructor from model.
void setDelta(CoinWorkDouble value)
CoinWorkDouble diagonalNorm_
diagonalNorm.
void gutsOfCopy(const ClpInterior &rhs)
Does most of copying.
void clearUpperBound(int sequence)
CoinWorkDouble actualDualStep_
actualDualStep
int maximumBarrierIterations() const
Maximum iterations.
CoinWorkDouble * cost_
Working copy of objective.
CoinWorkDouble sumDualInfeasibilities_
Sum of dual infeasibilities.
CoinWorkDouble * upperSlack_
upperSlack
CoinWorkDouble baseObjectiveNorm_
baseObjectiveNorm
bool primalFeasible() const
If problem is primal feasible.
void setUpperBound(int sequence)
To say a variable has upper bound.
CoinWorkDouble * solution_
solution
CoinWorkDouble * columnUpperWork_
Column upper bounds - working copy.
void deleteWorkingData()
int primalDual()
Primal-Dual Predictor-Corrector barrier.
ClpInterior & operator=(const ClpInterior &rhs)
Assignment operator. This copies the data.
CoinWorkDouble historyInfeasibility_[LENGTH_HISTORY]
ClpInterior(const ClpModel *wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns, bool dropNames=true, bool dropIntegers=true)
Subproblem constructor.
CoinWorkDouble * rhsZ_
rhsZ.
CoinWorkDouble diagonalNorm() const
diagonalNorm
CoinWorkDouble * dualR_
Dual regularization array.
void clearFlagged(int sequence)
void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub, const double *rowObjective=NULL)
CoinWorkDouble smallestInfeasibility_
smallestInfeasibility
void setLinearPerturbation(CoinWorkDouble value)
void setProjectionTolerance(CoinWorkDouble value)
void clearFakeLower(int sequence)
CoinWorkDouble * deltaSU_
deltaS.
CoinWorkDouble * rowLowerWork_
Row lower bounds - working copy.
int algorithm() const
Current (or last) algorithm.
int numberComplementarityItems_
numberComplementarityItems_ i.e. number of active bounds
ClpLsqr * lsqrObject_
Pointer to Lsqr object.
CoinWorkDouble maximumDualError_
maximumDualError.
CoinWorkDouble projectionTolerance() const
projectionTolerance
CoinWorkDouble primalObjective() const
primalObjective.
CoinWorkDouble maximumBoundInfeasibility_
maximumBoundInfeasibility.
int isColumn(int sequence) const
Returns 1 if sequence indicates column.
void setCholesky(ClpCholeskyBase *cholesky)
Set cholesky (and delete present one)
CoinWorkDouble solutionNorm_
solutionNorm.
CoinWorkDouble * diagonal_
diagonal
void clearFixed(int sequence)
CoinWorkDouble * dj_
void setFakeLower(int sequence)
To say a variable has fake lower bound.
int housekeeping()
This does housekeeping.
CoinWorkDouble * workArray_
work array
CoinWorkDouble linearPerturbation() const
linearPerturbation
CoinWorkDouble rhsNorm_
rhsNorm.
int numberComplementarityPairs_
numberComplementarityPairs i.e. ones with lower and/or upper bounds (not fixed)
CoinWorkDouble gamma() const
gamma
CoinWorkDouble quadraticDjs(CoinWorkDouble *djRegion, const CoinWorkDouble *solution, CoinWorkDouble scaleFactor)
Modifies djs to allow for quadratic.
CoinWorkDouble largestDualError_
Largest error on basic duals.
CoinWorkDouble * deltaSL_
CoinWorkDouble objectiveNorm_
objectiveNorm.
CoinWorkDouble dualObjective_
dualObjective.
bool dualFeasible() const
If problem is dual feasible.
CoinWorkDouble * deltaZ_
deltaZ.
void returnModel(ClpModel &otherModel)
Return model - updates any scalars.
ClpInterior()
Default constructor.
int pdco(ClpPdcoBase *stuff, Options &options, Info &info, Outfo &outfo)
CoinWorkDouble actualPrimalStep_
actualPrimalStep
CoinWorkDouble gamma_
CoinWorkDouble * rhsU_
rhsU.
void setAlgorithm(int value)
Set algorithm.
void setLowerBound(int sequence)
To say a variable has lower bound.
int algorithm_
Which algorithm being used.
int sequenceWithin(int sequence) const
Returns sequence number within section.
CoinWorkDouble * deltaW_
deltaW.
bool fakeUpper(int sequence) const
CoinWorkDouble * wVec_
wVec
void setFixed(int sequence)
To say a variable is fixed.
CoinWorkDouble delta() const
delta
CoinWorkDouble largestPrimalError_
Largest error on Ax-b.
CoinWorkDouble * rhsC_
rhs C
CoinWorkDouble sumPrimalInfeasibilities() const
Sum of primal infeasibilities.
CoinWorkDouble complementarityGap() const
ComplementarityGap.
void setFakeUpper(int sequence)
To say a variable has fake upper bound.
void checkSolution()
Checks solution.
ClpInterior(const ClpInterior &)
Copy constructor.
void clearLowerBound(int sequence)
ClpPdcoBase * pdcoStuff_
Pointer to stuff.
CoinWorkDouble maximumRHSChange_
maximumRHSChange
CoinWorkDouble delta_
This class implements LSQR.
Definition ClpLsqr.hpp:75
Abstract base class for Clp Matrices.
int numberColumns_
Number of columns.
unsigned char * status_
Status (i.e.
double * rowObjective() const
Row Objective.
Definition ClpModel.hpp:745
int numberColumns() const
Definition ClpModel.hpp:332
int numberRows() const
Number of rows.
Definition ClpModel.hpp:319
CoinPackedMatrix * matrix() const
Matrix (if not ClpPackedmatrix be careful about memory leak.
Definition ClpModel.hpp:772
double objectiveValue_
Objective value.
void dropNames()
Drops names - makes lengthnames 0 and names empty.
Abstract base class for tailoring everything for Pcdo.
******** DATA to be moved into protected section of ClpInterior
double atolmin
double r3norm
double * deltay
double LSdamp
******** DATA to be moved into protected section of ClpInterior
double z0min
double LSQRatol2
double FeaTol
double x0min
double mu0
double OptTol
double gamma
double StepTol
int LSproblem
double LSQRconlim
int LSQRMaxIter
double delta
double LSQRatol1
******** DATA to be moved into protected section of ClpInterior
int itncg
double r3ratio
int istop
double atolold
double atolnew