Home > Software engineering >  How to change a Variable type using OR-Tools and C#
How to change a Variable type using OR-Tools and C#

Time:10-21

Can someone give me an example (whether possible) of how to change the type of a linear variable after its creation?

For instance, I created first an integer variable x, but at some later point in my code, I decided to relax x to a continuous variable.

I could not find a way to do such a thing using the OR-Tools C# wrapper. I looked over the Variable and LinearSolver classes, and I searched for this here on this site, the google forum, and the GitHub issues.

Thanks in advance!

CodePudding user response:

You can use the following method in the variable class:

var.SetInteger(false);

See https://github.com/google/or-tools/blob/stable/ortools/linear_solver/csharp/linear_solver.i#L212

  • Related