public Variable[] MakeVarArray(int count, double lb, double ub, bool integer) { Variable[] array = new Variable[count]; for (int i = 0; i < count; ++i) { array[i] = MakeVar(lb, ub, integer, ""); } return array; }
public Variable[,] MakeVarMatrix(int rows, int cols, double lb, double ub, bool integer) { Variable[,] matrix = new Variable[rows, cols]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { matrix[i,j] = MakeVar(lb, ub, integer, ""); } } return matrix; }
public void BuildModel(Solver solver) { // Use vars.yourVariable to access variables in the variable store i.e. yourVariable // How to define a model using Google OR-Tools: https://developers.google.com/optimization/introduction/cs // Example model taken from https://developers.google.com/optimization/mip/integer_opt // Define the decision variables x = solver.MakeIntVar(0, 3.5, "x"); y = solver.MakeIntVar(0, double.PositiveInfinity, "y"); // Define the constraints solver.Add(x + 7 * y <= 17.5); // Define the objective solver.Maximize(x + 10 * y); }
public Variable[,] MakeVarMatrix(int rows, int cols, double lb, double ub, bool integer, string name) { Variable[,] matrix = new Variable[rows, cols]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { string var_name = name + "[" + i + ", " + j +"]"; matrix[i,j] = MakeVar(lb, ub, integer, var_name); } } return matrix; }
public void Maximize(Variable var) { Objective().Clear(); Objective().SetMaximization(); Objective().SetCoefficient(var, 1.0); }
public Variable[,] MakeBoolVarMatrix(int rows, int cols, string name) { Variable[,] matrix = new Variable[rows, cols]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { string var_name = name + "[" + i + ", " + j +"]"; matrix[i,j] = MakeBoolVar(var_name); } } return matrix; }
public Variable[,] MakeBoolVarMatrix(int rows, int cols) { Variable[,] matrix = new Variable[rows, cols]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { matrix[i,j] = MakeBoolVar(""); } } return matrix; }
public SumVarArray(Variable[] array) { this.array_ = array; }
public VarWrapper(Variable var) { this.var_ = var; }
public VarEquality(Variable left, Variable right, bool equality) { this.left_ = left; this.right_ = right; this.equality_ = equality; }