Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 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);
 }
Example #4
0
 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;
 }
Example #5
0
 public void Maximize(Variable var)
 {
   Objective().Clear();
   Objective().SetMaximization();
   Objective().SetCoefficient(var, 1.0);
 }
Example #6
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;
 }
Example #7
0
 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;
 }
Example #8
0
 public SumVarArray(Variable[] array)
 {
   this.array_ = array;
 }
Example #9
0
 public VarWrapper(Variable var)
 {
   this.var_ = var;
 }
Example #10
0
 public void Maximize(Variable var)
 {
     Objective().Clear();
     Objective().SetMaximization();
     Objective().SetCoefficient(var, 1.0);
 }
Example #11
0
 public VarEquality(Variable left, Variable right, bool equality)
 {
     this.left_     = left;
     this.right_    = right;
     this.equality_ = equality;
 }
Example #12
0
 public VarWrapper(Variable var)
 {
     this.var_ = var;
 }
Example #13
0
 public VarEquality(Variable left, Variable right, bool equality)
 {
   this.left_ = left;
   this.right_ = right;
   this.equality_ = equality;
 }