Loading...
Searching...
No Matches
ClpSolve.hpp
Go to the documentation of this file.
/* $Id$ */
// Copyright (C) 2003, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
/*
Authors
John Forrest
*/
#ifndef ClpSolve_H
#define ClpSolve_H
class ClpSolve {
public:
enum SolveType {
useDual = 0,
usePrimal,
usePrimalorSprint,
useBarrier,
useBarrierNoCross,
automatic,
tryDantzigWolfe,
tryBenders,
notImplemented
};
enum PresolveType {
presolveOn = 0,
presolveOff,
presolveNumber,
presolveNumberCost
};
ClpSolve();
ClpSolve(SolveType method, PresolveType presolveType,
int numberPasses, int options[6],
int extraInfo[6], int independentOptions[3]);
void generateCpp(FILE *fp);
ClpSolve(const ClpSolve &);
ClpSolve &operator=(const ClpSolve &rhs);
~ClpSolve();
void setSpecialOption(int which, int value, int extraInfo = -1);
int getSpecialOption(int which) const;
void setSolveType(SolveType method, int extraInfo = -1);
SolveType getSolveType();
// Presolve types
void setPresolveType(PresolveType amount, int extraInfo = -1);
PresolveType getPresolveType();
int getPresolvePasses() const;
int getExtraInfo(int which) const;
void setInfeasibleReturn(bool trueFalse);
inline bool infeasibleReturn() const
{
return independentOptions_[0] != 0;
}
inline bool doDual() const
{
return (independentOptions_[1] & 1) == 0;
}
inline void setDoDual(bool doDual_)
{
if (doDual_)
independentOptions_[1] &= ~1;
else
independentOptions_[1] |= 1;
}
inline bool doSingleton() const
{
return (independentOptions_[1] & 2) == 0;
}
inline void setDoSingleton(bool doSingleton_)
{
if (doSingleton_)
independentOptions_[1] &= ~2;
else
independentOptions_[1] |= 2;
}
inline bool doDoubleton() const
{
return (independentOptions_[1] & 4) == 0;
}
inline void setDoDoubleton(bool doDoubleton_)
{
if (doDoubleton_)
independentOptions_[1] &= ~4;
else
independentOptions_[1] |= 4;
}
inline bool doTripleton() const
{
return (independentOptions_[1] & 8) == 0;
}
inline void setDoTripleton(bool doTripleton_)
{
if (doTripleton_)
independentOptions_[1] &= ~8;
else
independentOptions_[1] |= 8;
}
inline bool doTighten() const
{
return (independentOptions_[1] & 16) == 0;
}
inline void setDoTighten(bool doTighten_)
{
if (doTighten_)
independentOptions_[1] &= ~16;
else
independentOptions_[1] |= 16;
}
inline bool doForcing() const
{
return (independentOptions_[1] & 32) == 0;
}
inline void setDoForcing(bool doForcing_)
{
if (doForcing_)
independentOptions_[1] &= ~32;
else
independentOptions_[1] |= 32;
}
inline bool doImpliedFree() const
{
return (independentOptions_[1] & 64) == 0;
}
inline void setDoImpliedFree(bool doImpliedfree)
{
if (doImpliedfree)
independentOptions_[1] &= ~64;
else
independentOptions_[1] |= 64;
}
inline bool doDupcol() const
{
return (independentOptions_[1] & 128) == 0;
}
inline void setDoDupcol(bool doDupcol_)
{
if (doDupcol_)
independentOptions_[1] &= ~128;
else
independentOptions_[1] |= 128;
}
inline bool doDuprow() const
{
return (independentOptions_[1] & 256) == 0;
}
inline void setDoDuprow(bool doDuprow_)
{
if (doDuprow_)
independentOptions_[1] &= ~256;
else
independentOptions_[1] |= 256;
}
inline bool doSingletonColumn() const
{
return (independentOptions_[1] & 512) == 0;
}
inline void setDoSingletonColumn(bool doSingleton_)
{
if (doSingleton_)
independentOptions_[1] &= ~512;
else
independentOptions_[1] |= 512;
}
inline bool doKillSmall() const
{
return (independentOptions_[1] & 8192) == 0;
}
inline void setDoKillSmall(bool doKill)
{
if (doKill)
independentOptions_[1] &= ~8192;
else
independentOptions_[1] |= 8192;
}
inline int presolveActions() const
{
return independentOptions_[1] & 0xffffff;
}
inline void setPresolveActions(int action)
{
independentOptions_[1] = (independentOptions_[1] & 0xff000000) | (action & 0xffffff);
}
inline int substitution() const
{
return independentOptions_[2];
}
inline void setSubstitution(int value)
{
independentOptions_[2] = value;
}
inline void setIndependentOption(int type, int value)
{
independentOptions_[type] = value;
}
inline int independentOption(int type) const
{
return independentOptions_[type];
}
private:
SolveType method_;
PresolveType presolveType_;
int numberPasses_;
int options_[7];
int extraInfo_[7];
int independentOptions_[3];
};
class ClpSimplexProgress {
public:
ClpSimplexProgress();
ClpSimplexProgress(ClpSimplex *model);
ClpSimplexProgress(const ClpSimplexProgress &);
ClpSimplexProgress &operator=(const ClpSimplexProgress &rhs);
~ClpSimplexProgress();
void reset();
void fillFromModel(ClpSimplex *model);
int looping();
void startCheck();
int cycle(int in, int out, int wayIn, int wayOut);
double lastObjective(int back = 1) const;
void setInfeasibility(double value);
double lastInfeasibility(int back = 1) const;
int numberInfeasibilities(int back = 1) const;
void modifyObjective(double value);
int lastIterationNumber(int back = 1) const;
void clearIterationNumbers();
inline void newOddState()
{
oddState_ = -oddState_ - 1;
}
inline void endOddState()
{
oddState_ = abs(oddState_);
}
inline void clearOddState()
{
oddState_ = 0;
}
inline int oddState() const
{
return oddState_;
}
inline int badTimes() const
{
return numberBadTimes_;
}
inline void clearBadTimes()
{
numberBadTimes_ = 0;
}
inline int reallyBadTimes() const
{
return numberReallyBadTimes_;
}
inline void incrementReallyBadTimes()
{
numberReallyBadTimes_++;
}
inline int timesFlagged() const
{
return numberTimesFlagged_;
}
inline void clearTimesFlagged()
{
numberTimesFlagged_ = 0;
}
inline void incrementTimesFlagged()
{
numberTimesFlagged_++;
}
#define CLP_PROGRESS 5
//#define CLP_PROGRESS_WEIGHT 10
double objective_[CLP_PROGRESS];
double infeasibility_[CLP_PROGRESS];
double realInfeasibility_[CLP_PROGRESS];
#ifdef CLP_PROGRESS_WEIGHT
double objectiveWeight_[CLP_PROGRESS_WEIGHT];
double infeasibilityWeight_[CLP_PROGRESS_WEIGHT];
double realInfeasibilityWeight_[CLP_PROGRESS_WEIGHT];
double drop_;
double best_;
#endif
double initialWeight_;
#define CLP_CYCLE 12
//double obj_[CLP_CYCLE];
int in_[CLP_CYCLE];
int out_[CLP_CYCLE];
char way_[CLP_CYCLE];
ClpSimplex *model_;
int numberInfeasibilities_[CLP_PROGRESS];
int iterationNumber_[CLP_PROGRESS];
#ifdef CLP_PROGRESS_WEIGHT
int numberInfeasibilitiesWeight_[CLP_PROGRESS_WEIGHT];
int iterationNumberWeight_[CLP_PROGRESS_WEIGHT];
#endif
int numberTimes_;
int numberBadTimes_;
int numberReallyBadTimes_;
int numberTimesFlagged_;
int oddState_;
};
#include "ClpConfig.h"
#if CLP_HAS_ABC
#include "AbcCommon.hpp"
class AbcSimplexProgress : public ClpSimplexProgress {
public:
AbcSimplexProgress();
AbcSimplexProgress(ClpSimplex *model);
AbcSimplexProgress(const AbcSimplexProgress &);
AbcSimplexProgress &operator=(const AbcSimplexProgress &rhs);
~AbcSimplexProgress();
int looping();
};
#endif
#endif
/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
*/
AbcCommon.hpp
type
CbcOrClpParameterType type() const
type
Definition CbcOrClpParam.hpp:462
ClpConfig.h
CLP_PROGRESS
#define CLP_PROGRESS
Definition ClpSolve.hpp:411
CLP_CYCLE
#define CLP_CYCLE
Definition ClpSolve.hpp:434
ClpSimplexProgress
For saving extra information to see if looping.
Definition ClpSolve.hpp:310
ClpSimplexProgress::realInfeasibility_
double realInfeasibility_[CLP_PROGRESS]
Sum of real primal infeasibilities for primal.
Definition ClpSolve.hpp:419
ClpSimplexProgress::numberTimes_
int numberTimes_
Number of times checked (so won't stop too early).
Definition ClpSolve.hpp:453
ClpSimplexProgress::way_
char way_[CLP_CYCLE]
Definition ClpSolve.hpp:439
ClpSimplexProgress::oddState_
int oddState_
If things are in an odd state.
Definition ClpSolve.hpp:461
ClpSimplexProgress::reset
void reset()
Resets as much as possible.
ClpSimplexProgress::clearOddState
void clearOddState()
Definition ClpSolve.hpp:369
ClpSimplexProgress::oddState
int oddState() const
Definition ClpSolve.hpp:373
ClpSimplexProgress::fillFromModel
void fillFromModel(ClpSimplex *model)
Fill from model.
ClpSimplexProgress::newOddState
void newOddState()
Odd state.
Definition ClpSolve.hpp:361
ClpSimplexProgress::startCheck
void startCheck()
Start check at beginning of whileIterating.
ClpSimplexProgress::numberInfeasibilities
int numberInfeasibilities(int back=1) const
Returns number of primal infeasibilities (if -1) - current if (0).
ClpSimplexProgress::numberReallyBadTimes_
int numberReallyBadTimes_
Number really bad times.
Definition ClpSolve.hpp:457
ClpSimplexProgress::modifyObjective
void modifyObjective(double value)
Modify objective e.g. if dual infeasible in dual.
ClpSimplexProgress::badTimes
int badTimes() const
number of bad times
Definition ClpSolve.hpp:378
ClpSimplexProgress::setInfeasibility
void setInfeasibility(double value)
Set real primal infeasibility and move back.
ClpSimplexProgress::endOddState
void endOddState()
Definition ClpSolve.hpp:365
ClpSimplexProgress::clearTimesFlagged
void clearTimesFlagged()
Definition ClpSolve.hpp:400
ClpSimplexProgress::initialWeight_
double initialWeight_
Initial weight for weights.
Definition ClpSolve.hpp:433
ClpSimplexProgress::infeasibility_
double infeasibility_[CLP_PROGRESS]
Sum of infeasibilities for algorithm.
Definition ClpSolve.hpp:417
ClpSimplexProgress::lastInfeasibility
double lastInfeasibility(int back=1) const
Returns real primal infeasibility (if -1) - current if (0).
ClpSimplexProgress::clearIterationNumbers
void clearIterationNumbers()
clears all iteration numbers (to switch off panic)
ClpSimplexProgress::reallyBadTimes
int reallyBadTimes() const
number of really bad times
Definition ClpSolve.hpp:387
ClpSimplexProgress::lastIterationNumber
int lastIterationNumber(int back=1) const
Returns previous iteration number (if -1) - current if (0).
ClpSimplexProgress::in_
int in_[CLP_CYCLE]
For cycle checking.
Definition ClpSolve.hpp:437
ClpSimplexProgress::incrementTimesFlagged
void incrementTimesFlagged()
Definition ClpSolve.hpp:404
ClpSimplexProgress::numberInfeasibilities_
int numberInfeasibilities_[CLP_PROGRESS]
Number of infeasibilities.
Definition ClpSolve.hpp:443
ClpSimplexProgress::looping
int looping()
Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken, >=0 if give up and use as p...
ClpSimplexProgress::lastObjective
double lastObjective(int back=1) const
Returns previous objective (if -1) - current if (0).
ClpSimplexProgress::cycle
int cycle(int in, int out, int wayIn, int wayOut)
Returns cycle length in whileIterating.
ClpSimplexProgress::clearBadTimes
void clearBadTimes()
Definition ClpSolve.hpp:382
ClpSimplexProgress::model_
ClpSimplex * model_
Pointer back to model so we can get information.
Definition ClpSolve.hpp:441
ClpSimplexProgress::iterationNumber_
int iterationNumber_[CLP_PROGRESS]
Iteration number at which occurred.
Definition ClpSolve.hpp:445
ClpSimplexProgress::timesFlagged
int timesFlagged() const
number of times flagged
Definition ClpSolve.hpp:396
ClpSimplexProgress::operator=
ClpSimplexProgress & operator=(const ClpSimplexProgress &rhs)
Assignment operator. This copies the data.
ClpSimplexProgress::~ClpSimplexProgress
~ClpSimplexProgress()
Destructor.
ClpSimplexProgress::objective_
double objective_[CLP_PROGRESS]
Objective values.
Definition ClpSolve.hpp:415
ClpSimplexProgress::numberBadTimes_
int numberBadTimes_
Number of times it looked like loop.
Definition ClpSolve.hpp:455
ClpSimplexProgress::ClpSimplexProgress
ClpSimplexProgress(const ClpSimplexProgress &)
Copy constructor.
ClpSimplexProgress::out_
int out_[CLP_CYCLE]
Definition ClpSolve.hpp:438
ClpSimplexProgress::ClpSimplexProgress
ClpSimplexProgress()
Default constructor.
ClpSimplexProgress::ClpSimplexProgress
ClpSimplexProgress(ClpSimplex *model)
Constructor from model.
ClpSimplexProgress::numberTimesFlagged_
int numberTimesFlagged_
Number of times no iterations as flagged.
Definition ClpSolve.hpp:459
ClpSimplexProgress::incrementReallyBadTimes
void incrementReallyBadTimes()
Definition ClpSolve.hpp:391
ClpSimplex
This solves LPs using the simplex method.
Definition ClpSimplex.hpp:106
ClpSolve::independentOptions_
int independentOptions_[3]
Extra algorithm dependent options 0 - if set return from clpsolve if infeasible 1 - To be copied over...
Definition ClpSolve.hpp:305
ClpSolve::setDoForcing
void setDoForcing(bool doForcing_)
Definition ClpSolve.hpp:189
ClpSolve::setDoDual
void setDoDual(bool doDual_)
Definition ClpSolve.hpp:129
ClpSolve::extraInfo_
int extraInfo_[7]
Extra information.
Definition ClpSolve.hpp:298
ClpSolve::ClpSolve
ClpSolve(SolveType method, PresolveType presolveType, int numberPasses, int options[6], int extraInfo[6], int independentOptions[3])
Constructor when you really know what you are doing.
ClpSolve::doSingletonColumn
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
Definition ClpSolve.hpp:233
ClpSolve::~ClpSolve
~ClpSolve()
Destructor.
ClpSolve::getExtraInfo
int getExtraInfo(int which) const
Extra info for idiot (or sprint).
ClpSolve::setDoSingletonColumn
void setDoSingletonColumn(bool doSingleton_)
Definition ClpSolve.hpp:237
ClpSolve::doDupcol
bool doDupcol() const
Whether we want to do dupcol part of presolve.
Definition ClpSolve.hpp:209
ClpSolve::setInfeasibleReturn
void setInfeasibleReturn(bool trueFalse)
Say to return at once if infeasible, default is to solve.
ClpSolve::doTripleton
bool doTripleton() const
Whether we want to do tripleton part of presolve.
Definition ClpSolve.hpp:161
ClpSolve::SolveType
SolveType
enums for solve function
Definition ClpSolve.hpp:24
ClpSolve::useDual
@ useDual
Definition ClpSolve.hpp:25
ClpSolve::tryBenders
@ tryBenders
Definition ClpSolve.hpp:32
ClpSolve::automatic
@ automatic
Definition ClpSolve.hpp:30
ClpSolve::useBarrier
@ useBarrier
Definition ClpSolve.hpp:28
ClpSolve::notImplemented
@ notImplemented
Definition ClpSolve.hpp:33
ClpSolve::tryDantzigWolfe
@ tryDantzigWolfe
Definition ClpSolve.hpp:31
ClpSolve::usePrimal
@ usePrimal
Definition ClpSolve.hpp:26
ClpSolve::usePrimalorSprint
@ usePrimalorSprint
Definition ClpSolve.hpp:27
ClpSolve::useBarrierNoCross
@ useBarrierNoCross
Definition ClpSolve.hpp:29
ClpSolve::setDoDuprow
void setDoDuprow(bool doDuprow_)
Definition ClpSolve.hpp:225
ClpSolve::presolveType_
PresolveType presolveType_
Presolve type.
Definition ClpSolve.hpp:292
ClpSolve::doTighten
bool doTighten() const
Whether we want to do tighten part of presolve.
Definition ClpSolve.hpp:173
ClpSolve::getSolveType
SolveType getSolveType()
ClpSolve::independentOption
int independentOption(int type) const
Definition ClpSolve.hpp:278
ClpSolve::operator=
ClpSolve & operator=(const ClpSolve &rhs)
Assignment operator. This copies the data.
ClpSolve::numberPasses_
int numberPasses_
Amount of presolve.
Definition ClpSolve.hpp:294
ClpSolve::ClpSolve
ClpSolve(const ClpSolve &)
Copy constructor.
ClpSolve::PresolveType
PresolveType
Definition ClpSolve.hpp:35
ClpSolve::presolveNumberCost
@ presolveNumberCost
Definition ClpSolve.hpp:39
ClpSolve::presolveOff
@ presolveOff
Definition ClpSolve.hpp:37
ClpSolve::presolveOn
@ presolveOn
Definition ClpSolve.hpp:36
ClpSolve::presolveNumber
@ presolveNumber
Definition ClpSolve.hpp:38
ClpSolve::substitution
int substitution() const
Largest column for substitution (normally 3).
Definition ClpSolve.hpp:266
ClpSolve::setPresolveActions
void setPresolveActions(int action)
Definition ClpSolve.hpp:261
ClpSolve::presolveActions
int presolveActions() const
Set whole group.
Definition ClpSolve.hpp:257
ClpSolve::method_
SolveType method_
Solve type.
Definition ClpSolve.hpp:290
ClpSolve::doForcing
bool doForcing() const
Whether we want to do forcing part of presolve.
Definition ClpSolve.hpp:185
ClpSolve::setSolveType
void setSolveType(SolveType method, int extraInfo=-1)
Solve types.
ClpSolve::getPresolvePasses
int getPresolvePasses() const
ClpSolve::setSubstitution
void setSubstitution(int value)
Definition ClpSolve.hpp:270
ClpSolve::doImpliedFree
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
Definition ClpSolve.hpp:197
ClpSolve::doDual
bool doDual() const
Whether we want to do dual part of presolve.
Definition ClpSolve.hpp:125
ClpSolve::setIndependentOption
void setIndependentOption(int type, int value)
Definition ClpSolve.hpp:274
ClpSolve::generateCpp
void generateCpp(FILE *fp)
Generates code for above constructor.
ClpSolve::getSpecialOption
int getSpecialOption(int which) const
ClpSolve::doKillSmall
bool doKillSmall() const
Whether we want to kill small substitutions.
Definition ClpSolve.hpp:245
ClpSolve::setDoImpliedFree
void setDoImpliedFree(bool doImpliedfree)
Definition ClpSolve.hpp:201
ClpSolve::setDoTripleton
void setDoTripleton(bool doTripleton_)
Definition ClpSolve.hpp:165
ClpSolve::setDoDupcol
void setDoDupcol(bool doDupcol_)
Definition ClpSolve.hpp:213
ClpSolve::options_
int options_[7]
Options - last is switch for OsiClp.
Definition ClpSolve.hpp:296
ClpSolve::doSingleton
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition ClpSolve.hpp:137
ClpSolve::doDuprow
bool doDuprow() const
Whether we want to do duprow part of presolve.
Definition ClpSolve.hpp:221
ClpSolve::setDoDoubleton
void setDoDoubleton(bool doDoubleton_)
Definition ClpSolve.hpp:153
ClpSolve::doDoubleton
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition ClpSolve.hpp:149
ClpSolve::getPresolveType
PresolveType getPresolveType()
ClpSolve::setDoSingleton
void setDoSingleton(bool doSingleton_)
Definition ClpSolve.hpp:141
ClpSolve::setSpecialOption
void setSpecialOption(int which, int value, int extraInfo=-1)
Special options - bits 0 4 - use crash (default allslack in dual, idiot in primal) 8 - all slack basi...
ClpSolve::setDoTighten
void setDoTighten(bool doTighten_)
Definition ClpSolve.hpp:177
ClpSolve::setDoKillSmall
void setDoKillSmall(bool doKill)
Definition ClpSolve.hpp:249
ClpSolve::setPresolveType
void setPresolveType(PresolveType amount, int extraInfo=-1)
ClpSolve::infeasibleReturn
bool infeasibleReturn() const
Definition ClpSolve.hpp:120
ClpSolve::ClpSolve
ClpSolve()
Default constructor.