13 #ifndef GAP_KNAP_PISINGER_INCLUDED
14 #define GAP_KNAP_PISINGER_INCLUDED
67 #include "UtilMacros.h"
88 const double epsTol = 1.0e-4) {
100 int i, scaleFactor = 1, n_aFrac = 0, factorToBig = 0;
101 double fractionalPart, rcFlipped;
102 double oneOverEps = 1.0 / epsTol;
105 if (redCost[i] >= 0) {
109 rcFlipped = -redCost[i];
113 fractionalPart *= oneOverEps;
114 m_workDbl[n_aFrac++] = (int)fractionalPart * (
double)epsTol;
118 for (i = 0; i < n_aFrac; i++) {
125 if (scaleFactor >= oneOverEps) {
145 const double* redCost,
146 const double* origCost,
148 vector<double>& solEls,
150 double& varOrigCost) {
168 vector<int> shrunkToOrig;
171 if (redCost[i] < 0.0) {
172 rcScaled = (-redCost[i]) * scaleFactor;
173 long rcLong =
static_cast<long>(floor(rcScaled + 0.5));
181 shrunkToOrig.push_back(i);
208 for (i = 0; i < nItems; i++) {
211 }
else if (nItems == 2) {
232 if ( (w0 + w1 <=
m_capacity) && (p0 + p1 > bestObj) ) {
237 }
else if (nItems > 2) {
239 item* lItem =
m_items + (nItems - 1);
261 for (i = 0; i < nItems; i++) {
263 j = shrunkToOrig[
m_items[i].i];
265 varRedCost += redCost[j];
266 varOrigCost += origCost[j];
267 solInd.push_back(origColIndex);
268 solEls.push_back(1.0);
289 "Error: Out of Memory");
290 memcpy(
m_weight, weight, nItems *
sizeof(
int));
291 memcpy(
m_profit, profit, nItems *
sizeof(
int));
const int getIndexIJ(const int i, const int j) const
bool UtilIsZero(const double x, const double etol=1.0e-8)
void solve(const int blockB, const double *redCost, const double *origCost, vector< int > &solInd, vector< double > &solEls, double &varRedCost, double &varOrigCost)
#define CoinAssertHint(expression, hint)
int calcScaleFactor(const double *redCost, const double epsTol=1.0e-4)
Types and protos for combo algorithm API:
GAP_KnapPisinger(const int nItems, const int capacity, const int *weight, const int *profit)
#define CoinAssertDebug(expression)
double UtilFracPart(const double x)
#define CoinAssert(expression)