Skip to content

CBC solver does not accept initial solution #229

@FGlazov

Description

@FGlazov

Describe the bug
The CBC solver does not initialize from an initial feasible solution, if one is provided. It maybe has something to do with the variables added via add_var_tensors, I'm not sure.

There is a closed issue #44 which is of a similar nature.

To Reproduce
Running the following code

from mip import Model, INTEGER, CONTINUOUS
from random import randint

m = Model("toy-model")

level1 = m.add_var_tensor(
    (8, 8),
    name='1',
    var_type=INTEGER,
    ub=10,
    lb=-10
)

level1_aux = m.add_var_tensor(
    (8, 8),
    name='1_aux',
    var_type=CONTINUOUS,
    ub=10,
    lb=-10,
    obj=1
)

level2 =  m.add_var_tensor(
    (4, 4),
    name='2',
    var_type=INTEGER,
    ub=10,
    lb=-10
)

level2_aux =  m.add_var_tensor(
    (4, 4),
    name='2_aux',
    var_type=CONTINUOUS,
    ub=10,
    lb=-10,
    obj=1
)

for base_var, aux_var in zip(level1.flatten(), level1_aux.flatten()):
    m += base_var <= aux_var
    m += -base_var <= aux_var
for base_var, aux_var in zip(level2.flatten(), level2_aux.flatten()):
    m += base_var <= aux_var
    m += -base_var <= aux_var

initial_solution = []
for x in range(0, 8):
    for y in range(0,8):
        value = randint(-10, 10)
        m += level1[x][y] + level2[x // 2][y // 2] == value
        initial_solution.append((level1[x][y], value))

m.start = initial_solution
m.optimize()

Results in the output

Cbc0045I Warning: MIPstart solution is not valid, column names do not match, ignoring it.

Expected behavior
The CBC solver should accept the initial solution and use it in order to improve performance.

Desktop (please complete the following information):

  • Operating System, version: Windows 10 with Linux subsystem (Ubuntu 20.04.1 LTS)
  • Python version: Python 3.8.10
  • Python-MIP version (we recommend you to test with the latest version): 1.13.0

Additional context

I noticed this behavior when I tried to dynamically create the levels described above (more than 2 levels) for a grid of values. The auxiliary variables are used for the sum of absolute values minimization trick: https://math.stackexchange.com/questions/623568/minimizing-the-sum-of-absolute-values-with-a-linear-solver/623569

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcbcAll items related to cbcreproducibleIf a bug/behaviour could be reproduced

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions