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