6 #ifndef ClpNonLinearCost_H 7 #define ClpNonLinearCost_H 9 #include "CoinPragma.hpp" 12 class CoinIndexedVector;
37 #define CLP_BELOW_LOWER 0 38 #define CLP_FEASIBLE 1 39 #define CLP_ABOVE_UPPER 2 51 status =
static_cast< unsigned char >(status & ~15);
52 status =
static_cast< unsigned char >(status | value);
56 status =
static_cast< unsigned char >(status & ~(15 << 4));
57 status =
static_cast< unsigned char >(status | (value << 4));
65 status =
static_cast< unsigned char >(status & ~(15 << 4));
66 status =
static_cast< unsigned char >(status | (
CLP_SAME << 4));
71 #define CLP_METHOD1 ((method_ & 1) != 0) 72 #define CLP_METHOD2 ((method_ & 2) != 0) 74 #define CLP_METHOD1 (false) 75 #define CLP_METHOD2 (true) 122 void checkChanged(
int numberInArray, CoinIndexedVector *update);
129 void goThru(
int numberInArray,
double multiplier,
130 const int *index,
const double *work,
134 void goBack(
int numberInArray,
const int *index,
141 void goBackAll(
const CoinIndexedVector *update);
155 double setOne(
int sequence,
double solutionValue);
158 void setOne(
int sequence,
double solutionValue,
double lowerValue,
double upperValue,
159 double costValue = 0.0);
165 double nearest(
int sequence,
double solutionValue);
171 double returnValue = 0.0;
175 returnValue =
cost_[iRange] -
cost_[iRange - 1];
177 returnValue =
cost_[iRange] -
cost_[iRange + 1];
186 double returnValue = 0.0;
190 returnValue =
cost_[iRange] -
cost_[iRange + 1];
192 returnValue = -1.0e100;
201 double returnValue = 0.0;
205 returnValue =
cost_[iRange] -
cost_[iRange - 1];
207 returnValue = 1.0e100;
217 double returnValue = 0.0;
219 double saveRhs = rhs;
224 assert(iRange - 1 >=
start_[sequence]);
227 returnValue = alpha * (
cost_[iRange] -
cost_[iRange - 1]);
229 assert(iRange + 1 <
start_[sequence + 1] - 1);
232 returnValue = alpha * (
cost_[iRange] -
cost_[iRange + 1]);
237 double saveRhs1 = rhs;
240 unsigned char iStatus =
status_[sequence];
268 assert(saveRhs1 == rhs);
275 inline double lower(
int sequence)
const 280 inline double upper(
int sequence)
const 285 inline double cost(
int sequence)
const 297 return (
status_[sequence] & 64) == 0;
357 return ((
infeasible_[i >> 5] >> (i & 31)) & 1) != 0;
366 value &= ~(1 << bit);
ClpSimplex * model_
Model.
double cost(int sequence) const
Returns current cost.
ClpNonLinearCost()
Default constructor.
double * cost2_
Feasible cost array.
void refreshCosts(const double *columnCosts)
Refreshes costs always makes row costs zero.
double sumInfeasibilities_
Sum of infeasibilities.
~ClpNonLinearCost()
Destructor.
void setMethod(int value)
double changeInCost() const
Change in cost.
ClpNonLinearCost & operator=(const ClpNonLinearCost &)
unsigned char * status_
Contains status at beginning and current.
double * cost_
Cost for each range.
void refresh()
Refresh - assuming regions OK.
int setOneOutgoing(int sequence, double &solutionValue)
Sets bounds and cost for outgoing variable may change value Returns direction.
void checkInfeasibilities(double oldTolerance=0.0)
Changes infeasible costs and computes number and cost of infeas Puts all non-basic (non free) variabl...
double changeCost_
Change in cost because of infeasibilities.
int originalStatus(unsigned char status)
int numberColumns_
Number of columns (mainly for checking and copy)
double changeDownInCost(int sequence) const
double largestInfeasibility_
Largest infeasibility.
double * lower_
Lower bound for each range (upper bound is next lower).
void setOriginalStatus(unsigned char &status, int value)
double changeInCost(int sequence, double alpha, double &rhs)
This also updates next bound.
void goThru(int numberInArray, double multiplier, const int *index, const double *work, double *rhs)
Goes through one bound for each variable.
void goBackAll(const CoinIndexedVector *update)
Puts back correct infeasible costs for each variable The input indices are row indices and need conve...
int method_
Method 1 old, 2 new, 3 both!
double averageTheta() const
Average theta.
double largestInfeasibility() const
Largest infeasibility.
bool infeasible(int i) const
double changeUpInCost(int sequence) const
int * start_
Starts for each entry (columns then rows)
double averageTheta_
Average theta - kept here as only for primal.
void setInitialStatus(unsigned char &status)
bool lookBothWays() const
See if may want to look both ways.
This solves LPs using the simplex method.
bool bothWays_
If we should look both ways for djs.
void setChangeInCost(double value)
#define CLP_BELOW_LOWER
Trivial class to deal with non linear costs.
int numberInfeasibilities() const
Number of infeasibilities.
bool changed(int sequence) const
Returns if changed from beginning of iteration.
double * upperRegion(int section) const
double lower(int sequence) const
Returns current lower bound.
double sumInfeasibilities() const
Sum of infeasibilities.
void goBack(int numberInArray, const int *index, double *rhs)
Takes off last iteration (i.e.
double * lowerRegion(int section) const
void validate()
For debug.
int * whichRange_
Range for each entry (columns then rows)
void zapCosts()
Temporary zeroing of feasible costs.
double upper(int sequence) const
Returns current upper bound.
double infeasibilityWeight_
Current infeasibility weight.
void feasibleBounds()
Puts feasible bounds into lower and upper.
unsigned char * statusArray() const
void setAverageTheta(double value)
double feasibleReportCost() const
Feasible cost with offset and direction (i.e. for reporting)
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.
double feasibleCost() const
Feasible cost.
double nearest(int sequence, double solutionValue)
Returns nearest bound.
void setInfeasible(int i, bool trueFalse)
int numberInfeasibilities_
Number of infeasibilities found.
int currentStatus(unsigned char status)
void setSameStatus(unsigned char &status)
int fullStatus(int sequence) const
Returns full status.
double * bound_
Bound which has been replaced in lower_ or upper_.
int numberRows_
Number of rows (mainly for checking and copy)
double feasibleCost_
Feasible cost.
void setCurrentStatus(unsigned char &status, int value)
int * offset_
Temporary range offset for each entry (columns then rows)
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_
bool convex_
If all non-linear costs convex.
double setOne(int sequence, double solutionValue)
Sets bounds and cost for one variable Returns change in cost May need to be inline for speed...