deleting variables - example
ユーザーの入力を待っています。The example in the documentation that is used for deleting variables, doesn't make a lot of sense to me. What are we saving in error? Does it update the model automatically
Example usage:
int first_two[] = {0, 1};
error = GRBdelvars(model, 2, first_two);
If I need t delete the last 900 variables that were added, can I do that?
I added variables with the same names and indices accidentally twice, and the model just added them instead of overwrote them. How can I delete those?
-
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
サインインしてコメントを残してください。
コメント
1件のコメント