Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
.NET Interface (C#)
This section will work through a simple C# example in order to illustrate the use of the Gurobi .NET interface. The example builds a model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the C# programming language. If not, a variety of books and websites are available for learning the language (for example, the Microsoft online C# documentation).
Our example optimizes the following model:
maximize | x | + | y | + | 2 z | ||
subject to | x | + | 2 y | + | 3 z | ![]() |
4 |
x | + | y | ![]() |
1 | |||
x, y, z binary |
Subsections
- Example mip1_cs.cs
- Example details
- Creating the environment
- Creating the model
- Adding variables to the model
- Updating the model - lazy modification
- Setting the objective
- Adding constraints to the model
- Optimizing the model
- Reporting results - attributes
- Cleaning up
- Error handling
- Building and running the example