4 #ifndef ClpNonLinearCost_H
5 #define ClpNonLinearCost_H
8 #include "CoinPragma.hpp"
11 class CoinIndexedVector;
36 #define CLP_BELOW_LOWER 0
37 #define CLP_FEASIBLE 1
38 #define CLP_ABOVE_UPPER 2
50 status =
static_cast<unsigned char>(status & ~15);
51 status =
static_cast<unsigned char>(status | value);
55 status =
static_cast<unsigned char>(status & ~(15 << 4));
56 status =
static_cast<unsigned char>(status | (value << 4));
64 status =
static_cast<unsigned char>(status & ~(15 << 4));
65 status =
static_cast<unsigned char>(status | (
CLP_SAME << 4));
70 #define CLP_METHOD1 ((method_&1)!=0)
71 #define CLP_METHOD2 ((method_&2)!=0)
73 #define CLP_METHOD1 (false)
74 #define CLP_METHOD2 (true)
97 const double *
lower,
const double *
cost);
124 void checkChanged(
int numberInArray, CoinIndexedVector * update);
131 void goThru(
int numberInArray,
double multiplier,
132 const int * index,
const double * work,
136 void goBack(
int numberInArray,
const int * index,
143 void goBackAll(
const CoinIndexedVector * update);
153 double setOne(
int sequence,
double solutionValue);
156 void setOne(
int sequence,
double solutionValue,
double lowerValue,
double upperValue,
157 double costValue = 0.0);
163 double nearest(
int sequence,
double solutionValue);
168 double returnValue = 0.0;
172 returnValue =
cost_[iRange] -
cost_[iRange-1];
174 returnValue = cost_[iRange] - cost_[iRange+1];
182 double returnValue = 0.0;
186 returnValue =
cost_[iRange] -
cost_[iRange+1];
188 returnValue = -1.0e100;
196 double returnValue = 0.0;
200 returnValue =
cost_[iRange] -
cost_[iRange-1];
202 returnValue = 1.0e100;
211 double returnValue = 0.0;
213 double saveRhs = rhs;
218 assert(iRange - 1 >=
start_[sequence]);
221 returnValue = alpha * (
cost_[iRange] -
cost_[iRange-1]);
223 assert(iRange + 1 <
start_[sequence+1] - 1);
226 returnValue = alpha * (
cost_[iRange] -
cost_[iRange+1]);
231 double saveRhs1 = rhs;
234 unsigned char iStatus =
status_[sequence];
262 assert(saveRhs1 == rhs);
269 inline double lower(
int sequence)
const {
273 inline double upper(
int sequence)
const {
277 inline double cost(
int sequence)
const {
335 value &= ~(1 << bit);
double changeCost_
Change in cost because of infeasibilities.
unsigned char * status_
Contains status at beginning and current.
~ClpNonLinearCost()
Destructor.
void setCurrentStatus(unsigned char &status, int value)
bool infeasible(int i) const
For debug.
double changeInCost(int sequence, double alpha) const
Returns change in cost - one down if alpha >0.0, up if <0.0 Value is current - new.
void checkChanged(int numberInArray, CoinIndexedVector *update)
Puts back correct infeasible costs for each variable The input indices are row indices and need conve...
unsigned int * infeasible_
Change in cost because of infeasibilities.
void setInfeasible(int i, bool trueFalse)
For debug.
void checkInfeasibilities(double oldTolerance=0.0)
Changes infeasible costs and computes number and cost of infeas Puts all non-basic (non free) variabl...
void setAverageTheta(double value)
Number of infeasibilities.
void refreshCosts(const double *columnCosts)
Refreshes costs always makes row costs zero.
double feasibleReportCost() const
Feasible cost with offset and direction (i.e. for reporting)
double sumInfeasibilities_
Sum of infeasibilities.
double changeInCost() const
Change in cost.
void zapCosts()
Temporary zeroing of feasible costs.
double * cost2_
Feasible cost array.
int * start_
Starts for each entry (columns then rows)
void goThru(int numberInArray, double multiplier, const int *index, const double *work, double *rhs)
Goes through one bound for each variable.
double * lowerRegion(int section) const
Return row or column sections - not as much needed as it once was.
double * bound_
Bound which has been replaced in lower_ or upper_.
double infeasibilityWeight_
Current infeasibility weight.
double changeUpInCost(int sequence) const
Changes infeasible costs and computes number and cost of infeas Puts all non-basic (non free) variabl...
int originalStatus(unsigned char status)
int numberRows_
Number of rows (mainly for checking and copy)
int * whichRange_
Range for each entry (columns then rows)
double setOne(int sequence, double solutionValue)
Sets bounds and cost for one variable Returns change in cost May need to be inline for speed...
bool lookBothWays() const
See if may want to look both ways.
int currentStatus(unsigned char status)
bool bothWays_
If we should look both ways for djs.
double * cost_
Cost for each range.
void goBackAll(const CoinIndexedVector *update)
Puts back correct infeasible costs for each variable The input indices are row indices and need conve...
double sumInfeasibilities() const
Sum of infeasibilities.
void setInitialStatus(unsigned char &status)
ClpSimplex * model_
Model.
unsigned char * statusArray() const
For debug.
int numberInfeasibilities_
Number of infeasibilities found.
double averageTheta() const
Average theta.
This solves LPs using the simplex method.
int numberColumns_
Number of columns (mainly for checking and copy)
double upper(int sequence) const
Returns current upper bound.
double changeDownInCost(int sequence) const
Changes infeasible costs and computes number and cost of infeas Puts all non-basic (non free) variabl...
bool convex_
If all non-linear costs convex.
double feasibleCost() const
Feasible cost.
void goBack(int numberInArray, const int *index, double *rhs)
Takes off last iteration (i.e.
double * upperRegion(int section) const
Return row or column sections - not as much needed as it once was.
#define CLP_BELOW_LOWER
Trivial class to deal with non linear costs.
void setChangeInCost(double value)
Number of infeasibilities.
void setSameStatus(unsigned char &status)
ClpNonLinearCost()
Default constructor.
int numberInfeasibilities() const
Number of infeasibilities.
int method_
Method 1 old, 2 new, 3 both!
void validate()
For debug.
double averageTheta_
Average theta - kept here as only for primal.
int * offset_
Temporary range offset for each entry (columns then rows)
double lower(int sequence) const
Returns current lower bound.
double feasibleCost_
Feasible cost.
double cost(int sequence) const
Returns current cost.
double nearest(int sequence, double solutionValue)
Returns nearest bound.
int setOneOutgoing(int sequence, double &solutionValue)
Sets bounds and cost for outgoing variable may change value Returns direction.
void setMethod(int value)
Number of infeasibilities.
void setOriginalStatus(unsigned char &status, int value)
ClpNonLinearCost & operator=(const ClpNonLinearCost &)
Default constructor.
double changeInCost(int sequence, double alpha, double &rhs)
This also updates next bound.
double * lower_
Lower bound for each range (upper bound is next lower).
void feasibleBounds()
Puts feasible bounds into lower and upper.
double largestInfeasibility() const
Largest infeasibility.
double largestInfeasibility_
Largest infeasibility.