Skip to main content

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

Answered

Comments

1 comment

  • 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

Please sign in to leave a comment.