Skip to main content

lower bounds of variables given by iterating over dictionary instead of matrix

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Riley Clement
    • Gurobi Staff

    Hi Hussein,

    Your B_lb dictionary has the following structure:
    keys = single indices for device
    values = list of lower bounds at each timestep

    But it needs to be structured like so (as per the addVars docs):
    keys = 2-tuple of (device,time step) pairs
    values = a single number, the lower bound, for the corresponding device and time step

    You can convert the former into the latter with the following code

    B_lb_new = {
        (device,time_step):lb 
        for device,lb_per_timestep in B_lb.items()
        for time_step,lb in enumerate(lb_per_timestep)
    }

    - Riley

    1

Post is closed for comments.