• Gurobi Staff

As far as I know, one can not get the reduced cost of a variable that has been added to the LP-model before one has run optimize again.

This is correct and we do not plan on adding this feature.

As an alternative, you could try running the Simplex algorithm with IterationLimit=0 and then access the RC attribute of the new variable. Note that you have to turn off presolve for that Presolve=0.

Best regards,
Jaromił

Thank you, this is very helpful!

Can you share why such a feature is not wanted?

I do encounter another issue. I'm running this line to get back to the default value after having done my check ( as according to https://www.gurobi.com/documentation/9.0/refman/presolve.html ).

 model.set(GRB_IntParam_Presolve, -1);

Then I get an 10008 Gurobi error. "Unable to set parameter Aggregate to value -1 (minimum is 0)"

I am using C++, Gurobi 9.0.2 and building on windows.

I can just continue without turning presolve back one, so it is not really a big issue for me right now, but it might be something you want to look into.

• Gurobi Staff

Can you share why such a feature is not wanted?

"Not wanted" is too strong. It is rather a convenience feature which can be implemented manually without much work. To get the reduced costs of a newly added variable, you could just implement one step of the Simplex algorithm (or just set the iteration limit to 0 as suggested).

I do encounter another issue. I'm running this line to get back to the default value after having done my check ( as according to https://www.gurobi.com/documentation/9.0/refman/presolve.html ).

 model.set(GRB_IntParam_Presolve, -1);

Then I get an 10008 Gurobi error. "Unable to set parameter Aggregate to value -1 (minimum is 0)"

I am using C++, Gurobi 9.0.2 and building on windows.

This sounds really strange, you are setting the Presolve parameter but the error message states that you are setting the Aggregate parameter. Could you post a minimal working example to reproduce this issue in C++?

Also, if you have the possibility to do so, then please ugprade to the latest Gurobi version.

Best regards,
Jaromił

Here is a minimal working example:

int main(int argc, char* argv[]){    try {        GRBEnv env;        GRBModel mod(env);        mod.set(GRB_IntParam_Presolve, -1);    }    catch (GRBException e) {        std::cout << "GRBError code: " << e.getErrorCode() << "\t" << e.getMessage() << "\n";    }    return 0;}

Which gives:

Academic license - for non-commercial use onlyGRBError code: 10008            Unable to set parameter Aggregate to value -1 (minimum is 0)

• Gurobi Staff

I cannot reproduce the issue. It might be a version mismatch between the C++ header and lib files. Could you please double check the C++ header file is the correct one used for your Gurobi version? You can find it in $$\texttt{<path_to_gurobi>/win64/include/gurobi_c++.h}$$.

To double check, could you please also try

GRBEnv env = GRBEnv();GRBModel model = GRBModel(env);model.set(GRB_IntParam_Presolve,-1);