メインコンテンツへスキップ

Re-optimization with a partial solution and new constraints

回答済み

コメント

2件のコメント

  • Jaromił Najman
    • Gurobi Staff

    Hi Charitha,

    Is there a particular reason why you create a copy of your model instead of directly working with the original model? If you would work with your original model, you would not have to write a model.sol file. You could just set the corresponding start attributes and add additional constraint to your model.

    Is your model a LP or a MIP? This is important to distinguish because a feasible solution usually does not help much if you work with an LP. If your model is an LP, you have to work with the Basis attributes VBasis and CBasis. If your model is a MIP, then working with the Start attribute or just reading in a (partial) solution file is the way to go.

    So, I want to keep part of the solution from the first optimization and re-optimize for a subset of variables with extra constraints (and maybe with a different objective function)

    Do you mean that you would like to fix some variables to the values that you found in a previous optimization run? If so, then you can fix a variable by setting its LB and UB attribute to the same value, e.g.,

    # fix variable x to 1
    x.LB = 1
    x.UB = 1

    Best regards, 
    Jaromił

     

    0
  • Charitha Buddhika Heendeniya
    • Gurobi-versary
    • Collaborator
    • Investigator

     Dear Jaromil,

    Is there a particular reason why you create a copy of your model instead of directly working with the original model?

    No. Anyway, I wanted to save the solution file for later inspection. I will continue based on your suggestion.

    Is your model a LP or a MIP?

    It is a MIP model.

    Do you mean that you would like to fix some variables to the values that you found in a previous optimization run? 

    Yes. I will follow your example. Thank you. 

    0

サインインしてコメントを残してください。