Skip to main content

A linear objective against a combination of variables.

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Richard Oberdieck
    • Gurobi Staff

    Hi John,

    thanks for reaching out.

    First of all, I would have modeled the expression slightly differently:

    2000*y <= A + B

    where y is an auxiliary binary variable. Combined with a high value in the objective function, this means that y "wants" to be 1, but can only do so if A+B >= 2000.

    However, what you say should also work equally well, so I think there may be a conceptual problem here. Do you only want to create a reward for passing 2000, or do you want to motivate the problem to get as high up to 2000 as possible?

    The key difference between these two statements it that in the first one, the problem will try to get to 2000, and if it cannot (as you suggested that it actually cannot), it will simply ignore that. In the second case, even if it cannot reach 2000, it will still push as much as possible to get there. To model that statement, I would write:

    maximize    X
    subject to X <= 2000
    X <= A + B

    What this does it that it tries to push A+B higher (which will increase X) up to the value 2000. If A+B > 2000, then the second constraint becomes non-binding (=redundant).

    Hope this helps, let me know.

    Best

    Richard

    0
  • John LeFlohic
    • Gurobi-versary
    • First Question
    • First Comment

    Thanks much Richard!  Both of those strategies help out a lot.  They both introduce me to the idea of using intermediary variables (y and X) to help shape the results.  To answer your question, in my case at least, I do indeed want to reward objective value smoothly all the way up to 2000 as well, not just once it hits 2000.

    I'll try your idea of using an X intermediary ("shepard") variable.  There's a chance it'll be more efficient than my latest implementation.  Currently, I use what I'm calling a slack variable: A + B + slackVariable >= 2000.  The slack variable ranges from 0 to 2000 but has a strong negative objective, encouraging it to get smaller, which implicitly ends up making A + B larger.  It's quite effective; but, I'm struggling to find ways to make it faster.

    So again, thanks much for the response Richard and I'm excited to try out the X "shepard variable" approach.

    0

Post is closed for comments.