15 #ifndef GAP_KNAP_PISINGER_INCLUDED
16 #define GAP_KNAP_PISINGER_INCLUDED
69 #include "UtilMacros.h"
90 const double epsTol = 1.0e-4) {
102 int i, scaleFactor = 1, n_aFrac = 0, factorToBig = 0;
103 double fractionalPart, rcFlipped;
104 double oneOverEps = 1.0 / epsTol;
107 if (redCost[i] >= 0) {
111 rcFlipped = -redCost[i];
115 fractionalPart *= oneOverEps;
116 m_workDbl[n_aFrac++] = (int)fractionalPart * (
double)epsTol;
120 for (i = 0; i < n_aFrac; i++) {
127 if (scaleFactor >= oneOverEps) {
147 const double* redCost,
148 const double* origCost,
150 vector<double>& solEls,
152 double& varOrigCost) {
170 vector<int> shrunkToOrig;
173 if (redCost[i] < 0.0) {
174 rcScaled = (-redCost[i]) * scaleFactor;
175 long rcLong =
static_cast<long>(floor(rcScaled + 0.5));
183 shrunkToOrig.push_back(i);
210 for (i = 0; i < nItems; i++) {
213 }
else if (nItems == 2) {
234 if ( (w0 + w1 <=
m_capacity) && (p0 + p1 > bestObj) ) {
239 }
else if (nItems > 2) {
241 item* lItem =
m_items + (nItems - 1);
263 for (i = 0; i < nItems; i++) {
265 j = shrunkToOrig[
m_items[i].i];
267 varRedCost += redCost[j];
268 varOrigCost += origCost[j];
269 solInd.push_back(origColIndex);
270 solEls.push_back(1.0);
291 "Error: Out of Memory");
292 memcpy(
m_weight, weight, nItems *
sizeof(
int));
293 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)