coin-or / coin-or/python-mip

MIP Start

Open
#233 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Linear Programming
Stars
600
Forks
108
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm trying to use the initial feasible solution from start attribute to solve MIP problems, when I use CBC solver to do so which is fine but while using Gurobi I found out the start attribite used by Gurobi is in upper case (m.Start instead of m.start). I'm nor sure it is an issue but I think it is better to use the same wording.

**To Reproduce**
So I use a if-else to implement this
```
if m.solver_name == 'GRB':
m.Start = [(m.x[v], m.x[v].x) for v in range(m.num_int)]
else:
m.start = [(m.x[v], m.x[v].x) for v in ​range(m.num_int)]
```

set_start function in gurobi.py

```
def set_start(self, start: List[Tuple[Var, float]]) -> None:
# collecting data
nz = len(start)
cind = ffi.new("int[]", [el[0].idx for el in start])
cval = ffi.new("double[]", [el[1] for el in start])

st = GRBsetdblattrlist(self._model, "Start".encode("utf-8"), nz, cind, cval)
if st != 0:
raise ParameterNotAvailable("Error modifying attribute Start")
self.__updated = False
```

set_start function in cbc.py

```
def set_start(self, start: List[Tuple[Var, numbers.Real]]) -> None:
n = len(start)
dv = ffi.new("double[]", [start[i][1] for i in range(n)])
keep_alive_str = [
ffi.new("char[]", str.encode(start[i][0].name)) for i in range(n)
]
var_names = ffi.new("char *[]", keep_alive_str)
mdl = self._model
cbclib.Cbc_setMIPStart(mdl, n, var_names, dv)
```

**Expected behavior**
Both using "start" or "Start"

**Desktop (please complete the following information):**
- Operating System, version: macOS 11.5.2
- Python version: 3.9.0
- Python-MIP version (we recommend you to test with the latest version): 1.13.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.