Skip to main content

Help translate mathematic model / optimization to Python

Answered

Comments

1 comment

  • Riley Clement
    • Gurobi Staff

    Hi Nizar,

    Check out our Jupyter Notebook Modeling Example for an Intro to Mathematical Optimization Modeling.

    This will provide a good foundation for converting your mathematical formulation into python code using gurobipy.

    For handling overlaps note that for two jobs, k and p, they do not overlap if either start(p) >= end(k) or if start(k) >= end(p) - you should draw diagrams if it helps convince you.  Therefore (using De Morgan's Laws) they overlap if start(p) < end(k) and start(k) < end(p).  You can apply this condition to each pair of jobs before even starting to construct your model to create a list of incompatible pairs, or you could create a function which takes two jobs and returns whether they overlap and use that while constructing your model.  While it is not wrong to have both \(x_{k,m} + x_{p,m} \leq 1\) and \(x_{p,m} + x_{k,m} \leq 1\)  it would not be helpful either, so make sure what when you calculating incompatible jobs you only consider unique pairs.

    - Riley

    0

Please sign in to leave a comment.