Skip to content

Suboptimal solution for multilinear relations #162

@ThibautCoudroy

Description

@ThibautCoudroy

Hello,

I'm using SCIP to solve a continuous multilinear problem. I have two equal formulations for the objective function but I found a case for which one formulation gives a far suboptimal solution. Yet, SCIP claims an optimal result for both formulations.

Here is the PySCIPOpt code. The main function is called twice, where the first execution/formulation gives the suboptimal result while the second execution/formulation gives the optimal one.

from pyscipopt import Model

RATIO, FLOW = 0, 1

def solve_problem(obj_func=RATIO):
    """Solve reconciliation problem for a given objective function
    The expected result is to have both formulations leading to the same solution,
    but here the RATIO one is significantly worse
    """

    model = Model()

    flows = [model.addVar(f"f{i}") for i in range(5)]
    model.addCons(sum(flows) == 300)

    weights = [model.addVar(f"s{i}_w", ub=1) for i in range(5)]
    for i in range(5):
        model.addCons(flows[i] * (weights[i]+1) == 100)

    # Two equivalent definitions for the objective function (since the constraints above are equalities)
    obj = model.addVar("obj")
    if obj_func == RATIO:
        model.addCons(obj >= sum([abs(0.9 - weights[i]) for i in range(5)]))
    else:
        model.addCons(obj >= sum([abs(0.9 - (100/flows[i] - 1)) for i in range(5)]))

    model.setObjective(obj)
    model.optimize()
    print(model.getBestSol())


if __name__ == "__main__":
    # Suboptimal minimization (obj=0.84)
    solve_problem(obj_func=RATIO)
    # Optimal minimization (obj=0.78)
    solve_problem(obj_func=FLOW)

First call result:
{'f0': 53.234780356212, 'f1': 89.7560785882046, 'f2': 52.258562416300194, 'f3': 52.49201622298299, 'f4': 52.258562416300194, 's0_w': 0.8784711673621274, 's1_w': 0.11413067027880895, 's2_w': 0.9135620131182284, 's3_w': 0.9050516106620469, 's4_w': 0.913562016031791, 'obj': 0.83957379917113}

Second call result:
{'f0': 52.63158306654943, 'f1': 52.631578975054545, 'f2': 89.4736555021569, 'f3': 52.63160348118459, 'f4': 52.631578975054545, 's0_w': 0.8999998512981086, 's1_w': 0.899999995642411, 's2_w': 0.11764741742991985, 's3_w': 0.8999991143293624, 's4_w': 0.899999999000531, 'obj': 0.782352681977184}

Expectation: Both objective values should be equal.

Note that there is a symmetry between the variables, so they should not be compared one to one.

I ran the same code on various situations (changing the number of flows, the value of the sum of flows and value used in the objective function), but this particular choice of values is the one for which the gap is the highest I have found. The second formulation (FLOW) always had a better result than the other (RATIO).

Some things I have tried:

  • Removing the upper bound of 1 on the weights solves the issue by providing the optimal result (that has every weight under 1) way faster than the other formulation. Changing it to any value greater than 1 also solves the issue.
  • Changing the bounds of weights from [0, 1] to [1, 2] and adapting consequently the constraints and objective function seem to fix the issue, but I'm unsure if it is luck or if it is handled differently

Is it expected that the results could be this different by substituting one element of the objective function with another variable linked by an equality?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions