Skip to content

Redefining initialization expression can lose the original result variable #270

Open

Description

@glebbelov

When redefining an expression (functional flat constraint) into another one, the original result variable can become disconnected from the replacement. Example where count(b1, b2), redefined into b1+b2, is lost:

var x >=0 <=10;
var y >=0 <=10;
var b1 binary;
var b2 binary;

s.t. DefB1: b1 <==> x >= 5;
s.t. DefB2: b2 <==> x >= 7;

## For Gurobi 12, max() requires outlining b1+b2.
## This is also enforced by acc:linfunccon=0.
## This converts "aux_var = b1+b2" into the corr.
## linear constraint and it's important to have
## the correct aux_var
s.t. UseLFC: y >= 6 || max(b1+b2, x-y) >= 2.3;

s.t. UseCount: y <= 4 || count(b1, b2) <= 1;

maximize OO: y+b1+b2;

This solves wrongly with current releases (although gives a checker warning) and fails with Debug builds.

  • Workaround: skip common subexpression elimination for the new expression, i.e., add its copy.
  • Need a proper fix, or is it good enough?

Activity

  1. self-assigned this
    on Oct 6, 2025
  2. added a commit that references this issue on Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions