Create a Copy of Gurobi Model in C#

30 views
Skip to first unread message

Ramiro Saltos Atiencia

unread,
Jun 17, 2016, 1:51:20 PM6/17/16
to Gurobi Optimization
Hi, I want to know how to create a copy of a gurobi model in C#.

GRBModel model = new GRBModel(Env);

GRBModel modelcopy = model;

I know that the second line is not correct because Gurobi Models are reference types. So if I make a change in modelcopy, the original model will change too. 

I want to implement a Branch and Bound and I need to create copies of my models to be used as nodes.

Thanks for your support.

Regards
Ramiro

Renan Garcia

unread,
Jun 17, 2016, 1:53:01 PM6/17/16
to gur...@googlegroups.com
To make a deep copy of a model, just use the GRBModel constructor with the original model as the argument (see http://www.gurobi.com/documentation/6.5/refman/cs_grbmodel2.html).

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ramiro Saltos Atiencia

unread,
Jun 17, 2016, 2:34:43 PM6/17/16
to Gurobi Optimization
Thanks a lot.
Reply all
Reply to author
Forward
0 new messages