Skip to main content

deleting variables - example

Awaiting user input

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.
  • Jaromił Najman
    • Gurobi Staff

    What are we saving in error?

    If the error is \(\neq 0\) then something unexpected happened, e.g., you tried to access a variable that is not present. For more details see Error Codes.

    Does it update the model automatically 

    No, see the documentation of the GRBdelvars function

    Delete a list of variables from an existing model. Note that, due to our lazy update approach, the variables won't actually be removed until you update the model (using GRBupdatemodel), optimize the model (using GRBoptimize), or write the model to disk (using GRBwrite).

    So, in order to directly remove the variables from the model, you have to call GRBupdatemodel after executing the GRBdelvars function.

    If  I need t delete the last 900 variables that were added, can I do that?

    Yes, you can delete the last 900 variables as long as you have their indices. You can then provide the indices as the \(\texttt{*ind}\) argument in the GRBdelvars function.

    I added variables with the same names and indices accidentally twice, and the model just added them instead of overwrote them.

    Could you share a minimal reproducible example of how you add the variables with 2 indices? The GRBaddvars  function should have returned a DUPLICATES error, i.e., the call

    error = GRBaddvars(...)

    should have returned an \(\texttt{error}\) value that is \(\neq 0\).

    Best regards, 
    Jaromił

    0

Post is closed for comments.