Go to the documentation of this file.
6 #ifndef ClpNonLinearCost_H
7 #define ClpNonLinearCost_H
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)
129 void goThru(
int numberInArray,
double multiplier,
130 const int *index,
const double *work,
134 void goBack(
int numberInArray,
const int *index,
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;
173 int iRange = whichRange_[sequence] + offset_[sequence];
175 returnValue = cost_[iRange] - cost_[iRange - 1];
177 returnValue = cost_[iRange] - cost_[iRange + 1];
180 returnValue = (alpha > 0.0) ? infeasibilityWeight_ : -infeasibilityWeight_;
186 double returnValue = 0.0;
188 int iRange = whichRange_[sequence] + offset_[sequence];
189 if (iRange + 1 != start_[sequence + 1] && !
infeasible(iRange + 1))
190 returnValue = cost_[iRange] - cost_[iRange + 1];
192 returnValue = -1.0e100;
195 returnValue = -infeasibilityWeight_;
201 double returnValue = 0.0;
203 int iRange = whichRange_[sequence] + offset_[sequence];
204 if (iRange != start_[sequence] && !
infeasible(iRange - 1))
205 returnValue = cost_[iRange] - cost_[iRange - 1];
207 returnValue = 1.0e100;
210 returnValue = infeasibilityWeight_;
217 double returnValue = 0.0;
219 double saveRhs = rhs;
222 int iRange = whichRange_[sequence] + offset_[sequence];
224 assert(iRange - 1 >= start_[sequence]);
226 rhs += lower_[iRange] - lower_[iRange - 1];
227 returnValue = alpha * (cost_[iRange] - cost_[iRange - 1]);
229 assert(iRange + 1 < start_[sequence + 1] - 1);
231 rhs += lower_[iRange + 2] - lower_[iRange + 1];
232 returnValue = alpha * (cost_[iRange] - cost_[iRange + 1]);
237 double saveRhs1 = rhs;
240 unsigned char iStatus = status_[sequence];
259 rhs += bound_[sequence] - model_->
upperRegion()[sequence];
264 rhs += model_->
lowerRegion()[sequence] - bound_[sequence];
268 assert(saveRhs1 == rhs);
270 returnValue = fabs(alpha) * infeasibilityWeight_;
275 inline double lower(
int sequence)
const
277 return lower_[whichRange_[sequence] + offset_[sequence]];
280 inline double upper(
int sequence)
const
282 return lower_[whichRange_[sequence] + offset_[sequence] + 1];
285 inline double cost(
int sequence)
const
287 return cost_[whichRange_[sequence] + offset_[sequence]];
292 return status_[sequence];
297 return (status_[sequence] & 64) == 0;
307 return numberInfeasibilities_;
317 return feasibleCost_;
324 return sumInfeasibilities_;
329 return largestInfeasibility_;
334 return averageTheta_;
338 averageTheta_ = value;
357 return ((infeasible_[i >> 5] >> (i & 31)) & 1) != 0;
361 unsigned int &value = infeasible_[i >> 5];
366 value &= ~(1 << bit);
382 double feasibleCost_;
384 double infeasibilityWeight_;
386 double largestInfeasibility_;
388 double sumInfeasibilities_;
390 double averageTheta_;
410 unsigned int *infeasible_;
412 int numberInfeasibilities_;
415 unsigned char *status_;
This solves LPs using the simplex method.
void setChangeInCost(double value)
const double COIN_DBL_MAX
int setOneOutgoing(int sequence, double &solutionValue)
Sets bounds and cost for outgoing variable may change value Returns direction.
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 validate()
For debug.
void zapCosts()
Temporary zeroing of feasible costs.
double changeUpInCost(int sequence) const
double lower(int sequence) const
Returns current lower bound.
void feasibleBounds()
Puts feasible bounds into lower and upper.
unsigned char * statusArray() const
double feasibleReportCost() const
Feasible cost with offset and direction (i.e. for reporting)
double averageTheta() const
Average theta.
double setOne(int sequence, double solutionValue)
Sets bounds and cost for one variable Returns change in cost May need to be inline for speed.
~ClpNonLinearCost()
Destructor.
int originalStatus(unsigned char status)
int numberInfeasibilities() const
Number of infeasibilities.
void checkInfeasibilities(double oldTolerance=0.0)
Changes infeasible costs and computes number and cost of infeas Puts all non-basic (non free) variabl...
int fullStatus(int sequence) const
Returns full status.
void setAverageTheta(double value)
void refresh()
Refresh - assuming regions OK.
double upper(int sequence) const
Returns current upper bound.
double cost(int sequence) const
Returns current cost.
void setMethod(int value)
#define CLP_BELOW_LOWER
Trivial class to deal with non linear costs.
double feasibleCost() const
Feasible cost.
double * upperRegion(int section) const
ClpNonLinearCost & operator=(const ClpNonLinearCost &)
void refreshCosts(const double *columnCosts)
Refreshes costs always makes row costs zero.
int currentStatus(unsigned char status)
double nearest(int sequence, double solutionValue)
Returns nearest bound.
void goBackAll(const CoinIndexedVector *update)
Puts back correct infeasible costs for each variable The input indices are row indices and need conve...
void setOriginalStatus(unsigned char &status, int value)
double largestInfeasibility() const
Largest infeasibility.
double changeDownInCost(int sequence) const
ClpNonLinearCost()
Default constructor.
bool lookBothWays() const
See if may want to look both ways.
double changeInCost() const
Change in cost.
void setInitialStatus(unsigned char &status)
double sumInfeasibilities() const
Sum of infeasibilities.
void goBack(int numberInArray, const int *index, double *rhs)
Takes off last iteration (i.e.
void checkChanged(int numberInArray, CoinIndexedVector *update)
Puts back correct infeasible costs for each variable The input indices are row indices and need conve...
bool changed(int sequence) const
Returns if changed from beginning of iteration.
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
void setCurrentStatus(unsigned char &status, int value)
double changeInCost(int sequence, double alpha, double &rhs)
This also updates next bound.
void setInfeasible(int i, bool trueFalse)
bool infeasible(int i) const
void setSameStatus(unsigned char &status)