OR-Tools  9.0
linear_programming_constraint.h
Go to the documentation of this file.
1 // Copyright 2010-2021 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef OR_TOOLS_SAT_LINEAR_PROGRAMMING_CONSTRAINT_H_
15 #define OR_TOOLS_SAT_LINEAR_PROGRAMMING_CONSTRAINT_H_
16 
17 #include <cstdint>
18 #include <limits>
19 #include <utility>
20 #include <vector>
21 
22 #include "absl/container/flat_hash_map.h"
23 #include "ortools/base/int_type.h"
29 #include "ortools/sat/cuts.h"
31 #include "ortools/sat/integer.h"
35 #include "ortools/sat/model.h"
36 #include "ortools/sat/util.h"
38 #include "ortools/util/rev.h"
40 
41 namespace operations_research {
42 namespace sat {
43 
44 // Stores for each IntegerVariable its temporary LP solution.
45 //
46 // This is shared between all LinearProgrammingConstraint because in the corner
47 // case where we have many different LinearProgrammingConstraint and a lot of
48 // variable, we could theoretically use up a quadratic amount of memory
49 // otherwise.
50 //
51 // TODO(user): find a better way?
53  : public absl::StrongVector<IntegerVariable, double> {
55 };
56 
57 // Helper struct to combine info generated from solving LP.
58 struct LPSolveInfo {
60  double lp_objective = -std::numeric_limits<double>::infinity();
62 };
63 
64 // Simple class to combine linear expression efficiently. First in a sparse
65 // way that switch to dense when the number of non-zeros grows.
67  public:
68  // This must be called with the correct size before any other functions are
69  // used.
70  void ClearAndResize(int size);
71 
72  // Does vector[col] += value and return false in case of overflow.
73  bool Add(glop::ColIndex col, IntegerValue value);
74 
75  // Similar to Add() but for multiplier * terms.
76  // Returns false in case of overflow.
78  IntegerValue multiplier,
79  const std::vector<std::pair<glop::ColIndex, IntegerValue>>& terms);
80 
81  // This is not const only because non_zeros is sorted. Note that sorting the
82  // non-zeros make the result deterministic whether or not we were in sparse
83  // mode.
84  //
85  // TODO(user): Ideally we should convert to IntegerVariable as late as
86  // possible. Prefer to use GetTerms().
88  const std::vector<IntegerVariable>& integer_variables,
89  IntegerValue upper_bound, LinearConstraint* result);
90 
91  // Similar to ConvertToLinearConstraint().
92  std::vector<std::pair<glop::ColIndex, IntegerValue>> GetTerms();
93 
94  // We only provide the const [].
95  IntegerValue operator[](glop::ColIndex col) const {
96  return dense_vector_[col];
97  }
98 
99  private:
100  // If is_sparse is true we maintain the non_zeros positions and bool vector
101  // of dense_vector_. Otherwise we don't. Note that we automatically switch
102  // from sparse to dense as needed.
103  bool is_sparse_ = true;
104  std::vector<glop::ColIndex> non_zeros_;
106 
107  // The dense representation of the vector.
109 };
110 
111 // A SAT constraint that enforces a set of linear inequality constraints on
112 // integer variables using an LP solver.
113 //
114 // The propagator uses glop's revised simplex for feasibility and propagation.
115 // It uses the Reduced Cost Strengthening technique, a classic in mixed integer
116 // programming, for instance see the thesis of Tobias Achterberg,
117 // "Constraint Integer Programming", sections 7.7 and 8.8, algorithm 7.11.
118 // http://nbn-resolving.de/urn:nbn:de:0297-zib-11129
119 //
120 // Per-constraint bounds propagation is NOT done by this constraint,
121 // it should be done by redundant constraints, as reduced cost propagation
122 // may miss some filtering.
123 //
124 // Note that this constraint works with double floating-point numbers, so one
125 // could be worried that it may filter too much in case of precision issues.
126 // However, by default, we interpret the LP result by recomputing everything
127 // in integer arithmetic, so we are exact.
128 class LinearProgrammingDispatcher;
131  public:
132  typedef glop::RowIndex ConstraintIndex;
133 
135  ~LinearProgrammingConstraint() override;
136 
137  // Add a new linear constraint to this LP.
139 
140  // Set the coefficient of the variable in the objective. Calling it twice will
141  // overwrite the previous value.
142  void SetObjectiveCoefficient(IntegerVariable ivar, IntegerValue coeff);
143 
144  // The main objective variable should be equal to the linear sum of
145  // the arguments passed to SetObjectiveCoefficient().
146  void SetMainObjectiveVariable(IntegerVariable ivar) { objective_cp_ = ivar; }
147 
148  // Register a new cut generator with this constraint.
149  void AddCutGenerator(CutGenerator generator);
150 
151  // Returns the LP value and reduced cost of a variable in the current
152  // solution. These functions should only be called when HasSolution() is true.
153  //
154  // Note that this solution is always an OPTIMAL solution of an LP above or
155  // at the current decision level. We "erase" it when we backtrack over it.
156  bool HasSolution() const { return lp_solution_is_set_; }
157  double SolutionObjectiveValue() const { return lp_objective_; }
158  double GetSolutionValue(IntegerVariable variable) const;
159  double GetSolutionReducedCost(IntegerVariable variable) const;
160  bool SolutionIsInteger() const { return lp_solution_is_integer_; }
161 
162  // PropagatorInterface API.
163  bool Propagate() override;
164  bool IncrementalPropagate(const std::vector<int>& watch_indices) override;
165  void RegisterWith(Model* model);
166 
167  // ReversibleInterface API.
168  void SetLevel(int level) override;
169 
170  int NumVariables() const { return integer_variables_.size(); }
171  const std::vector<IntegerVariable>& integer_variables() const {
172  return integer_variables_;
173  }
174  std::string DimensionString() const { return lp_data_.GetDimensionString(); }
175 
176  // Returns a IntegerLiteral guided by the underlying LP constraints.
177  //
178  // This looks at all unassigned 0-1 variables, takes the one with
179  // a support value closest to 0.5, and tries to assign it to 1.
180  // If all 0-1 variables have an integer support, returns kNoLiteralIndex.
181  // Tie-breaking is done using the variable natural order.
182  //
183  // TODO(user): This fixes to 1, but for some problems fixing to 0
184  // or to the std::round(support value) might work better. When this is the
185  // case, change behaviour automatically?
187 
188  // Returns a IntegerLiteral guided by the underlying LP constraints.
189  //
190  // This computes the mean of reduced costs over successive calls,
191  // and tries to fix the variable which has the highest reduced cost.
192  // Tie-breaking is done using the variable natural order.
193  // Only works for 0/1 variables.
194  //
195  // TODO(user): Try to get better pseudocosts than averaging every time
196  // the heuristic is called. MIP solvers initialize this with strong branching,
197  // then keep track of the pseudocosts when doing tree search. Also, this
198  // version only branches on var >= 1 and keeps track of reduced costs from var
199  // = 1 to var = 0. This works better than the conventional MIP where the
200  // chosen variable will be argmax_var min(pseudocost_var(0->1),
201  // pseudocost_var(1->0)), probably because we are doing DFS search where MIP
202  // does BFS. This might depend on the model, more trials are necessary. We
203  // could also do exponential smoothing instead of decaying every N calls, i.e.
204  // pseudo = a * pseudo + (1-a) reduced.
206 
207  // Returns a IntegerLiteral guided by the underlying LP constraints.
208  //
209  // This computes the mean of reduced costs over successive calls,
210  // and tries to fix the variable which has the highest reduced cost.
211  // Tie-breaking is done using the variable natural order.
213 
214  // Average number of nonbasic variables with zero reduced costs.
215  double average_degeneracy() const {
216  return average_degeneracy_.CurrentAverage();
217  }
218 
220  return total_num_simplex_iterations_;
221  }
222 
223  private:
224  // Helper methods for branching. Returns true if branching on the given
225  // variable helps with more propagation or finds a conflict.
226  bool BranchOnVar(IntegerVariable var);
227  LPSolveInfo SolveLpForBranching();
228 
229  // Helper method to fill reduced cost / dual ray reason in 'integer_reason'.
230  // Generates a set of IntegerLiterals explaining why the best solution can not
231  // be improved using reduced costs. This is used to generate explanations for
232  // both infeasibility and bounds deductions.
233  void FillReducedCostReasonIn(const glop::DenseRow& reduced_costs,
234  std::vector<IntegerLiteral>* integer_reason);
235 
236  // Reinitialize the LP from a potentially new set of constraints.
237  // This fills all data structure and properly rescale the underlying LP.
238  //
239  // Returns false if the problem is UNSAT (it can happen when presolve is off
240  // and some LP constraint are trivially false).
241  bool CreateLpFromConstraintManager();
242 
243  // Solve the LP, returns false if something went wrong in the LP solver.
244  bool SolveLp();
245 
246  // Add a "MIR" cut obtained by first taking the linear combination of the
247  // row of the matrix according to "integer_multipliers" and then trying
248  // some integer rounding heuristic.
249  //
250  // Return true if a new cut was added to the cut manager.
251  bool AddCutFromConstraints(
252  const std::string& name,
253  const std::vector<std::pair<glop::RowIndex, IntegerValue>>&
254  integer_multipliers);
255 
256  // Second half of AddCutFromConstraints().
257  bool PostprocessAndAddCut(
258  const std::string& name, const std::string& info,
259  IntegerVariable first_new_var, IntegerVariable first_slack,
260  const std::vector<ImpliedBoundsProcessor::SlackInfo>& ib_slack_infos,
261  LinearConstraint* cut);
262 
263  // Computes and adds the corresponding type of cuts.
264  // This can currently only be called at the root node.
265  void AddCGCuts();
266  void AddMirCuts();
267  void AddZeroHalfCuts();
268 
269  // Updates the bounds of the LP variables from the CP bounds.
270  void UpdateBoundsOfLpVariables();
271 
272  // Use the dual optimal lp values to compute an EXACT lower bound on the
273  // objective. Fills its reason and perform reduced cost strenghtening.
274  // Returns false in case of conflict.
275  bool ExactLpReasonning();
276 
277  // Same as FillDualRayReason() but perform the computation EXACTLY. Returns
278  // false in the case that the problem is not provably infeasible with exact
279  // computations, true otherwise.
280  bool FillExactDualRayReason();
281 
282  // Returns number of non basic variables with zero reduced costs.
283  int64_t CalculateDegeneracy();
284 
285  // From a set of row multipliers (at LP scale), scale them back to the CP
286  // world and then make them integer (eventually multiplying them by a new
287  // scaling factor returned in *scaling).
288  //
289  // Note that this will loose some precision, but our subsequent computation
290  // will still be exact as it will work for any set of multiplier.
291  std::vector<std::pair<glop::RowIndex, IntegerValue>> ScaleLpMultiplier(
292  bool take_objective_into_account,
293  const std::vector<std::pair<glop::RowIndex, double>>& lp_multipliers,
294  glop::Fractional* scaling, int max_pow = 62) const;
295 
296  // Computes from an integer linear combination of the integer rows of the LP a
297  // new constraint of the form "sum terms <= upper_bound". All computation are
298  // exact here.
299  //
300  // Returns false if we encountered any integer overflow.
301  bool ComputeNewLinearConstraint(
302  const std::vector<std::pair<glop::RowIndex, IntegerValue>>&
303  integer_multipliers,
304  ScatteredIntegerVector* scattered_vector,
305  IntegerValue* upper_bound) const;
306 
307  // Simple heuristic to try to minimize |upper_bound - ImpliedLB(terms)|. This
308  // should make the new constraint tighter and correct a bit the imprecision
309  // introduced by rounding the floating points values.
310  void AdjustNewLinearConstraint(
311  std::vector<std::pair<glop::RowIndex, IntegerValue>>* integer_multipliers,
312  ScatteredIntegerVector* scattered_vector,
313  IntegerValue* upper_bound) const;
314 
315  // Shortcut for an integer linear expression type.
316  using LinearExpression = std::vector<std::pair<glop::ColIndex, IntegerValue>>;
317 
318  // Converts a dense represenation of a linear constraint to a sparse one
319  // expressed in terms of IntegerVariable.
320  void ConvertToLinearConstraint(
322  IntegerValue upper_bound, LinearConstraint* result);
323 
324  // Compute the implied lower bound of the given linear expression using the
325  // current variable bound. Return kMinIntegerValue in case of overflow.
326  IntegerValue GetImpliedLowerBound(const LinearConstraint& terms) const;
327 
328  // Tests for possible overflow in the propagation of the given linear
329  // constraint.
330  bool PossibleOverflow(const LinearConstraint& constraint);
331 
332  // Reduce the coefficient of the constraint so that we cannot have overflow
333  // in the propagation of the given linear constraint. Note that we may loose
334  // some strength by doing so.
335  //
336  // We make sure that any partial sum involving any variable value in their
337  // domain do not exceed 2 ^ max_pow.
338  void PreventOverflow(LinearConstraint* constraint, int max_pow = 62);
339 
340  // Fills integer_reason_ with the reason for the implied lower bound of the
341  // given linear expression. We relax the reason if we have some slack.
342  void SetImpliedLowerBoundReason(const LinearConstraint& terms,
343  IntegerValue slack);
344 
345  // Fills the deductions vector with reduced cost deductions that can be made
346  // from the current state of the LP solver. The given delta should be the
347  // difference between the cp objective upper bound and lower bound given by
348  // the lp.
349  void ReducedCostStrengtheningDeductions(double cp_objective_delta);
350 
351  // Returns the variable value on the same scale as the CP variable value.
352  glop::Fractional GetVariableValueAtCpScale(glop::ColIndex var);
353 
354  // Gets or creates an LP variable that mirrors a CP variable.
355  // The variable should be a positive reference.
356  glop::ColIndex GetOrCreateMirrorVariable(IntegerVariable positive_variable);
357 
358  // This must be called on an OPTIMAL LP and will update the data for
359  // LPReducedCostAverageDecision().
360  void UpdateAverageReducedCosts();
361 
362  // Callback underlying LPReducedCostAverageBranching().
363  IntegerLiteral LPReducedCostAverageDecision();
364 
365  // Updates the simplex iteration limit for the next visit.
366  // As per current algorithm, we use a limit which is dependent on size of the
367  // problem and drop it significantly if degeneracy is detected. We use
368  // DUAL_FEASIBLE status as a signal to correct the prediction. The next limit
369  // is capped by 'min_iter' and 'max_iter'. Note that this is enabled only for
370  // linearization level 2 and above.
371  void UpdateSimplexIterationLimit(const int64_t min_iter,
372  const int64_t max_iter);
373 
374  // This epsilon is related to the precision of the value/reduced_cost returned
375  // by the LP once they have been scaled back into the CP domain. So for large
376  // domain or cost coefficient, we may have some issues.
377  static constexpr double kCpEpsilon = 1e-4;
378 
379  // Same but at the LP scale.
380  static constexpr double kLpEpsilon = 1e-6;
381 
382  // Anything coming from the LP with a magnitude below that will be assumed to
383  // be zero.
384  static constexpr double kZeroTolerance = 1e-12;
385 
386  // Class responsible for managing all possible constraints that may be part
387  // of the LP.
388  LinearConstraintManager constraint_manager_;
389 
390  // Initial problem in integer form.
391  // We always sort the inner vectors by increasing glop::ColIndex.
392  struct LinearConstraintInternal {
393  IntegerValue lb;
394  IntegerValue ub;
395  LinearExpression terms;
396  };
397  LinearExpression integer_objective_;
398  IntegerValue integer_objective_offset_ = IntegerValue(0);
399  IntegerValue objective_infinity_norm_ = IntegerValue(0);
402 
403  // Underlying LP solver API.
404  glop::LinearProgram lp_data_;
405  glop::RevisedSimplex simplex_;
406  int64_t next_simplex_iter_ = 500;
407 
408  // For the scaling.
409  glop::LpScalingHelper scaler_;
410 
411  // Temporary data for cuts.
412  ZeroHalfCutHelper zero_half_cut_helper_;
413  CoverCutHelper cover_cut_helper_;
414  IntegerRoundingCutHelper integer_rounding_cut_helper_;
415  LinearConstraint cut_;
416 
417  ScatteredIntegerVector tmp_scattered_vector_;
418 
419  std::vector<double> tmp_lp_values_;
420  std::vector<IntegerValue> tmp_var_lbs_;
421  std::vector<IntegerValue> tmp_var_ubs_;
422  std::vector<glop::RowIndex> tmp_slack_rows_;
423  std::vector<IntegerValue> tmp_slack_bounds_;
424 
425  // Used by ScaleLpMultiplier().
426  mutable std::vector<std::pair<glop::RowIndex, double>> tmp_cp_multipliers_;
427 
428  // Structures used for mirroring IntegerVariables inside the underlying LP
429  // solver: an integer variable var is mirrored by mirror_lp_variable_[var].
430  // Note that these indices are dense in [0, mirror_lp_variable_.size()] so
431  // they can be used as vector indices.
432  //
433  // TODO(user): This should be absl::StrongVector<glop::ColIndex,
434  // IntegerVariable>.
435  std::vector<IntegerVariable> integer_variables_;
436  absl::flat_hash_map<IntegerVariable, glop::ColIndex> mirror_lp_variable_;
437 
438  // We need to remember what to optimize if an objective is given, because
439  // then we will switch the objective between feasibility and optimization.
440  bool objective_is_defined_ = false;
441  IntegerVariable objective_cp_;
442 
443  // Singletons from Model.
444  const SatParameters& sat_parameters_;
445  Model* model_;
446  TimeLimit* time_limit_;
447  IntegerTrail* integer_trail_;
448  Trail* trail_;
449  IntegerEncoder* integer_encoder_;
450  ModelRandomGenerator* random_;
451 
452  // Used while deriving cuts.
453  ImpliedBoundsProcessor implied_bounds_processor_;
454 
455  // The dispatcher for all LP propagators of the model, allows to find which
456  // LinearProgrammingConstraint has a given IntegerVariable.
457  LinearProgrammingDispatcher* dispatcher_;
458 
459  std::vector<IntegerLiteral> integer_reason_;
460  std::vector<IntegerLiteral> deductions_;
461  std::vector<IntegerLiteral> deductions_reason_;
462 
463  // Repository of IntegerSumLE that needs to be kept around for the lazy
464  // reasons. Those are new integer constraint that are created each time we
465  // solve the LP to a dual-feasible solution. Propagating these constraints
466  // both improve the objective lower bound but also perform reduced cost
467  // fixing.
468  int rev_optimal_constraints_size_ = 0;
469  std::vector<std::unique_ptr<IntegerSumLE>> optimal_constraints_;
470 
471  // Last OPTIMAL solution found by a call to the underlying LP solver.
472  // On IncrementalPropagate(), if the bound updates do not invalidate this
473  // solution, Propagate() will not find domain reductions, no need to call it.
474  int lp_solution_level_ = 0;
475  bool lp_solution_is_set_ = false;
476  bool lp_solution_is_integer_ = false;
477  double lp_objective_;
478  std::vector<double> lp_solution_;
479  std::vector<double> lp_reduced_cost_;
480 
481  // If non-empty, this is the last known optimal lp solution at root-node. If
482  // the variable bounds changed, or cuts where added, it is possible that this
483  // solution is no longer optimal though.
484  std::vector<double> level_zero_lp_solution_;
485 
486  // True if the last time we solved the exact same LP at level zero, no cuts
487  // and no lazy constraints where added.
488  bool lp_at_level_zero_is_final_ = false;
489 
490  // Same as lp_solution_ but this vector is indexed differently.
491  LinearProgrammingConstraintLpSolution& expanded_lp_solution_;
492 
493  // Linear constraints cannot be created or modified after this is registered.
494  bool lp_constraint_is_registered_ = false;
495 
496  std::vector<CutGenerator> cut_generators_;
497 
498  // Store some statistics for HeuristicLPReducedCostAverage().
499  bool compute_reduced_cost_averages_ = false;
500  int num_calls_since_reduced_cost_averages_reset_ = 0;
501  std::vector<double> sum_cost_up_;
502  std::vector<double> sum_cost_down_;
503  std::vector<int> num_cost_up_;
504  std::vector<int> num_cost_down_;
505  std::vector<double> rc_scores_;
506 
507  // All the entries before rev_rc_start_ in the sorted positions correspond
508  // to fixed variables and can be ignored.
509  int rev_rc_start_ = 0;
510  RevRepository<int> rc_rev_int_repository_;
511  std::vector<std::pair<double, int>> positions_by_decreasing_rc_score_;
512 
513  // Defined as average number of nonbasic variables with zero reduced costs.
514  IncrementalAverage average_degeneracy_;
515  bool is_degenerate_ = false;
516 
517  // Used by the strong branching heuristic.
518  int branching_frequency_ = 1;
519  int64_t count_since_last_branching_ = 0;
520 
521  // Sum of all simplex iterations performed by this class. This is useful to
522  // test the incrementality and compare to other solvers.
523  int64_t total_num_simplex_iterations_ = 0;
524 
525  // Some stats on the LP statuses encountered.
526  std::vector<int64_t> num_solves_by_status_;
527 };
528 
529 // A class that stores which LP propagator is associated to each variable.
530 // We need to give the hash_map a name so it can be used as a singleton in our
531 // model.
532 //
533 // Important: only positive variable do appear here.
535  : public absl::flat_hash_map<IntegerVariable,
536  LinearProgrammingConstraint*> {
537  public:
539 };
540 
541 // A class that stores the collection of all LP constraints in a model.
543  : public std::vector<LinearProgrammingConstraint*> {
544  public:
546 };
547 
548 // Cut generator for the circuit constraint, where in any feasible solution, the
549 // arcs that are present (variable at 1) must form a circuit through all the
550 // nodes of the graph. Self arc are forbidden in this case.
551 //
552 // In more generality, this currently enforce the resulting graph to be strongly
553 // connected. Note that we already assume basic constraint to be in the lp, so
554 // we do not add any cuts for components of size 1.
556  int num_nodes, const std::vector<int>& tails, const std::vector<int>& heads,
557  const std::vector<Literal>& literals, Model* model);
558 
559 // Almost the same as CreateStronglyConnectedGraphCutGenerator() but for each
560 // components, computes the demand needed to serves it, and depending on whether
561 // it contains the depot (node zero) or not, compute the minimum number of
562 // vehicle that needs to cross the component border.
563 CutGenerator CreateCVRPCutGenerator(int num_nodes,
564  const std::vector<int>& tails,
565  const std::vector<int>& heads,
566  const std::vector<Literal>& literals,
567  const std::vector<int64_t>& demands,
568  int64_t capacity, Model* model);
569 } // namespace sat
570 } // namespace operations_research
571 
572 #endif // OR_TOOLS_SAT_LINEAR_PROGRAMMING_CONSTRAINT_H_
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
Definition: time_limit.h:105
std::string GetDimensionString() const
Definition: lp_data.cc:425
std::function< IntegerLiteral()> HeuristicLpReducedCostBinary(Model *model)
bool IncrementalPropagate(const std::vector< int > &watch_indices) override
std::function< IntegerLiteral()> HeuristicLpMostInfeasibleBinary(Model *model)
const std::vector< IntegerVariable > & integer_variables() const
void SetObjectiveCoefficient(IntegerVariable ivar, IntegerValue coeff)
Class that owns everything related to a particular optimization model.
Definition: sat/model.h:38
void ConvertToLinearConstraint(const std::vector< IntegerVariable > &integer_variables, IntegerValue upper_bound, LinearConstraint *result)
bool Add(glop::ColIndex col, IntegerValue value)
std::vector< std::pair< glop::ColIndex, IntegerValue > > GetTerms()
bool AddLinearExpressionMultiple(IntegerValue multiplier, const std::vector< std::pair< glop::ColIndex, IntegerValue >> &terms)
const std::string name
const Constraint * ct
int64_t value
IntVar * var
Definition: expr_array.cc:1874
double upper_bound
GRBmodel * model
ColIndex col
Definition: markowitz.cc:183
CutGenerator CreateCVRPCutGenerator(int num_nodes, const std::vector< int > &tails, const std::vector< int > &heads, const std::vector< Literal > &literals, const std::vector< int64_t > &demands, int64_t capacity, Model *model)
constexpr IntegerValue kMinIntegerValue(-kMaxIntegerValue)
CutGenerator CreateStronglyConnectedGraphCutGenerator(int num_nodes, const std::vector< int > &tails, const std::vector< int > &heads, const std::vector< Literal > &literals, Model *model)
Collection of objects used to extend the Constraint Solver library.
int64_t capacity