Skip to content

fixed handling of infinite bounds on variables #22

@svigerske

Description

@svigerske

Issue created by migration from Trac.

Original creator: mkaut

Original creation time: 2009-09-22 13:15:21

Assignee: somebody

Version: 1.0

New variables are created with upper-bound equal to the infinity from defaultModel. If this happens to differ from the solver's infinity (as it does for glpk), strange things happen.

I propose to fixed it in the MP_model::assert() method, i.e. right before we create the Osi object.
This means replacing lines 366-371 in MP_model.cpp:

  for (varIt i=Variables.begin(); i!=Variables.end(); i++) {
    for (int k=0; k<(*i)->size(); k++) {
      l[(*i)->offset+k] = (*i)->lowerLimit.v[k];
      u[(*i)->offset+k] = (*i)->upperLimit.v[k];
    }
  }

by the following:
// Any unlimited bounds are set using getDefaultModel().getInfinity().
// If the solver's infinity is different, this would create problems...
double defInf = getDefaultModel().getInfinity();
for (varIt i=Variables.begin(); i!=Variables.end(); i++) {
for (int k=0; k<(*i)->size(); k++) {
if ((*i)->lowerLimit.v[k] == -defInf) { // is '==' OK for double?
l[(*i)->offset+k] = -inf;
} else {
l[(*i)->offset+k] = (*i)->lowerLimit.v[k];
}
if ((*i)->upperLimit.v[k] == defInf) { // is '==' OK for double?
u[(*i)->offset+k] = inf;
} else {
u[(*i)->offset+k] = (*i)->upperLimit.v[k];
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions