OR-Tools  9.0
gscip.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 // Simplified bindings for the SCIP solver. This is not designed to be used
15 // directly by users, the API is not friendly to a modeler. For most common
16 // cases, use MPSolver instead.
17 //
18 // Notable differences between gSCIP and SCIP:
19 // * Unless callbacks are used, gSCIP only exposes the SCIP stage PROBLEM to
20 // the user through public APIs.
21 // * Instead of the stateful SCIP parameters API, parameters are passed in at
22 // Solve() time and cleared at the end of solve. Parameters that effect
23 // problem creation are thus not supported.
24 // * gSCIP uses std::numeric_limits<double>::infinity(), rather than SCIPs
25 // infinity (a default value of 1e20). Doubles with absolute value >= 1e20
26 // are automatically converting to std::numeric_limits<double>::infinity()
27 // by gSCIP. Changing the underlying SCIP's infinity is not supported.
28 // * absl::Status and absl::StatusOr are used to propagate SCIP errors (and on
29 // a best effort basis, also filter out bad input to gSCIP functions).
30 //
31 // A note on error propagation and reliability:
32 // Many methods on SCIP return an error code. Errors can be triggered by
33 // both invalid input and bugs in SCIP. We propagate these errors back to the
34 // user through gSCIP through Status and StatusOr. If you are solving a single
35 // MIP and you have previously successfully solved similar MIPs, it is unlikely
36 // gSCIP would return any status errors. Depending on your application, CHECK
37 // failing on these errors may be appropriate (e.g. a benchmark that is run by
38 // hand). If you are solving a very large number of MIPs (e.g. in a flume job),
39 // your instances are numerically challenging, or the model/data are drawn from
40 // an unreliable source, or you are running a server that cannot crash, you may
41 // want to try and process these errors instead. Note that on bad instances,
42 // SCIP may still crash, so highly reliable systems should run SCIP in a
43 // separate process.
44 //
45 // NOTE(user): much of the API uses const std::string& instead of
46 // absl::string_view because the underlying SCIP API needs a null terminated
47 // char*.
48 #ifndef OR_TOOLS_GSCIP_GSCIP_H_
49 #define OR_TOOLS_GSCIP_GSCIP_H_
50 
51 #include <cstdint>
52 #include <functional>
53 #include <limits>
54 #include <memory>
55 #include <string>
56 #include <vector>
57 
58 #include "absl/container/flat_hash_map.h"
59 #include "absl/container/flat_hash_set.h"
60 #include "absl/status/status.h"
61 #include "absl/status/statusor.h"
62 #include "absl/strings/string_view.h"
63 #include "absl/types/span.h"
64 #include "ortools/gscip/gscip.pb.h"
65 #include "ortools/gscip/gscip_message_handler.h" // IWYU pragma: export
66 #include "scip/scip.h"
67 #include "scip/scip_prob.h"
68 #include "scip/type_cons.h"
69 #include "scip/type_scip.h"
70 #include "scip/type_var.h"
71 
72 namespace operations_research {
73 
74 using GScipSolution = absl::flat_hash_map<SCIP_VAR*, double>;
75 
76 // The result of GScip::Solve(). Contains the solve status, statistics, and the
77 // solutions found.
78 struct GScipResult {
79  GScipOutput gscip_output;
80  // The number of solutions returned is at most GScipParameters::num_solutions.
81  // They are ordered from best objective value to worst. When
82  // gscip_output.status() is optimal, solutions will have at least one element.
83  std::vector<GScipSolution> solutions;
84  // Of the same size as solutions.
85  std::vector<double> objective_values;
86  // Advanced use below
87 
88  // If the problem was unbounded, a primal ray in the unbounded direction of
89  // the LP relaxation should be produced.
90  absl::flat_hash_map<SCIP_VAR*, double> primal_ray;
91  // TODO(user): add dual support:
92  // 1. The dual solution for LPs.
93  // 2. The dual ray for infeasible LP/MIPs.
94 };
95 
96 // Models the constraint lb <= a*x <= ub. Members variables and coefficients
97 // must have the same size.
99  double lower_bound = -std::numeric_limits<double>::infinity();
100  std::vector<SCIP_VAR*> variables;
101  std::vector<double> coefficients;
102  double upper_bound = std::numeric_limits<double>::infinity();
103 };
104 
105 // A variable is implied integer if the integrality constraint is not required
106 // for the model to be valid, but the variable takes an integer value in any
107 // optimal solution to the problem.
109 
110 struct GScipIndicatorConstraint;
111 struct GScipLogicalConstraintData;
112 // Some advanced features, defined at the end of the header file.
113 struct GScipQuadraticRange;
114 struct GScipSOSData;
115 struct GScipVariableOptions;
116 
117 const GScipVariableOptions& DefaultGScipVariableOptions();
118 struct GScipConstraintOptions;
119 
120 const GScipConstraintOptions& DefaultGScipConstraintOptions();
121 using GScipBranchingPriority = absl::flat_hash_map<SCIP_VAR*, int>;
122 enum class GScipHintResult;
123 
124 // A thin wrapper around the SCIP solver that provides C++ bindings that are
125 // idiomatic for Google. Unless callbacks are used, the SCIP stage is always
126 // PROBLEM.
127 class GScip {
128  public:
129  // Create a new GScip (the constructor is private). The default objective
130  // direction is minimization.
131  static absl::StatusOr<std::unique_ptr<GScip>> Create(
132  const std::string& problem_name);
133  ~GScip();
134  static std::string ScipVersion();
135 
136  // After Solve() the parameters are reset and SCIP stage is restored to
137  // PROBLEM. "legacy_params" are in the format of legacy_scip_params.h and are
138  // applied after "params". Use of "legacy_params" is discouraged.
139  //
140  // The returned StatusOr will contain an error only if an:
141  // * An underlying function from SCIP fails.
142  // * There is an I/O error with managing SCIP output.
143  // The above cases are not mutually exclusive. If the problem is infeasible,
144  // this will be reflected in the value of GScipResult::gscip_output::status.
145  absl::StatusOr<GScipResult> Solve(
146  const GScipParameters& params = GScipParameters(),
147  const std::string& legacy_params = "",
148  GScipMessageHandler message_handler = nullptr);
149 
150  // ///////////////////////////////////////////////////////////////////////////
151  // Basic Model Construction
152  // ///////////////////////////////////////////////////////////////////////////
153 
154  // Use true for maximization, false for minimization.
155  absl::Status SetMaximize(bool is_maximize);
156  absl::Status SetObjectiveOffset(double offset);
157 
158  // The returned SCIP_VAR is owned by GScip. With default options, the
159  // returned variable will have the same lifetime as GScip (if instead,
160  // GScipVariableOptions::keep_alive is false, SCIP may free the variable at
161  // any time, see GScipVariableOptions::keep_alive for details).
162  absl::StatusOr<SCIP_VAR*> AddVariable(
163  double lb, double ub, double obj_coef, GScipVarType var_type,
164  const std::string& var_name = "",
166 
167  // The returned SCIP_CONS is owned by GScip. With default options, the
168  // returned variable will have the same lifetime as GScip (if instead,
169  // GScipConstraintOptions::keep_alive is false, SCIP may free the constraint
170  // at any time, see GScipConstraintOptions::keep_alive for details).
171  //
172  // Can be called while creating the model or in a callback (e.g. in a
173  // GScipConstraintHandler).
174  absl::StatusOr<SCIP_CONS*> AddLinearConstraint(
175  const GScipLinearRange& range, const std::string& name = "",
177 
178  // ///////////////////////////////////////////////////////////////////////////
179  // Model Queries
180  // ///////////////////////////////////////////////////////////////////////////
181 
182  bool ObjectiveIsMaximize();
183  double ObjectiveOffset();
184 
185  double Lb(SCIP_VAR* var);
186  double Ub(SCIP_VAR* var);
187  double ObjCoef(SCIP_VAR* var);
188  GScipVarType VarType(SCIP_VAR* var);
189  absl::string_view Name(SCIP_VAR* var);
190  const absl::flat_hash_set<SCIP_VAR*>& variables() { return variables_; }
191 
192  // These methods works on all constraint types.
193  absl::string_view Name(SCIP_CONS* constraint);
194  bool IsConstraintLinear(SCIP_CONS* constraint);
195  const absl::flat_hash_set<SCIP_CONS*>& constraints() { return constraints_; }
196 
197  // These methods will CHECK fail if constraint is not a linear constraint.
198  absl::Span<const double> LinearConstraintCoefficients(SCIP_CONS* constraint);
199  absl::Span<SCIP_VAR* const> LinearConstraintVariables(SCIP_CONS* constraint);
200  double LinearConstraintLb(SCIP_CONS* constraint);
201  double LinearConstraintUb(SCIP_CONS* constraint);
202 
203  // ///////////////////////////////////////////////////////////////////////////
204  // Model Updates (needed for incrementalism)
205  // ///////////////////////////////////////////////////////////////////////////
206  absl::Status SetLb(SCIP_VAR* var, double lb);
207  absl::Status SetUb(SCIP_VAR* var, double ub);
208  absl::Status SetObjCoef(SCIP_VAR* var, double obj_coef);
209  absl::Status SetVarType(SCIP_VAR* var, GScipVarType var_type);
210 
211  // Warning: you need to ensure that no constraint has a reference to this
212  // variable before deleting it, or undefined behavior will occur. For linear
213  // constraints, you can set the coefficient of this variable to zero to remove
214  // the variable from the constriant.
215  absl::Status DeleteVariable(SCIP_VAR* var);
216 
217  // Checks if SafeBulkDelete will succeed for vars, and returns a description
218  // the problematic variables/constraints on a failure (the returned status
219  // will not contain a propagated SCIP error). Will not modify the underyling
220  // SCIP, it is safe to continue using this if an error is returned.
221  absl::Status CanSafeBulkDelete(const absl::flat_hash_set<SCIP_VAR*>& vars);
222 
223  // Attempts to remove vars from all constraints and then remove vars from
224  // the model. As of August 7, 2020, will fail if the model contains any
225  // constraints that are not linear.
226  //
227  // Will call CanSafeBulkDelete above, but can also return an error Status
228  // propagated from SCIP. Do not assume SCIP is in a valid state if this fails.
229  absl::Status SafeBulkDelete(const absl::flat_hash_set<SCIP_VAR*>& vars);
230 
231  // These methods will CHECK fail if constraint is not a linear constraint.
232  absl::Status SetLinearConstraintLb(SCIP_CONS* constraint, double lb);
233  absl::Status SetLinearConstraintUb(SCIP_CONS* constraint, double ub);
234  absl::Status SetLinearConstraintCoef(SCIP_CONS* constraint, SCIP_VAR* var,
235  double value);
236 
237  // Works on all constraint types. Unlike DeleteVariable, no special action is
238  // required before deleting a constraint.
239  absl::Status DeleteConstraint(SCIP_CONS* constraint);
240 
241  // ///////////////////////////////////////////////////////////////////////////
242  // Nonlinear constraint types.
243  // For now, only basic support (adding to the model) is provided. Reading and
244  // updating support may be added in the future.
245  // ///////////////////////////////////////////////////////////////////////////
246 
247  // Adds a constraint of the form:
248  // if z then a * x <= b
249  // where z is a binary variable, x is a vector of decision variables, a is
250  // vector of constants, and b is a constant. z can be negated.
251  //
252  // NOTE(user): options.modifiable is ignored.
253  absl::StatusOr<SCIP_CONS*> AddIndicatorConstraint(
254  const GScipIndicatorConstraint& indicator_constraint,
255  const std::string& name = "",
257 
258  // Adds a constraint of form lb <= x * Q * x + a * x <= ub.
259  //
260  // NOTE(user): options.modifiable and options.sticking_at_node are ignored.
261  absl::StatusOr<SCIP_CONS*> AddQuadraticConstraint(
262  const GScipQuadraticRange& range, const std::string& name = "",
264 
265  // Adds the constraint:
266  // logical_data.resultant = AND_i logical_data.operators[i],
267  // where logical_data.resultant and logical_data.operators[i] are all binary
268  // variables.
269  absl::StatusOr<SCIP_CONS*> AddAndConstraint(
270  const GScipLogicalConstraintData& logical_data,
271  const std::string& name = "",
273 
274  // Adds the constraint:
275  // logical_data.resultant = OR_i logical_data.operators[i],
276  // where logical_data.resultant and logical_data.operators[i] must be binary
277  // variables.
278  absl::StatusOr<SCIP_CONS*> AddOrConstraint(
279  const GScipLogicalConstraintData& logical_data,
280  const std::string& name = "",
282 
283  // Adds the constraint that at most one of the variables in sos_data can be
284  // nonzero. The variables can be integer or continuous. See GScipSOSData for
285  // details.
286  //
287  // NOTE(user): options.modifiable is ignored (these constraints are not
288  // modifiable).
289  absl::StatusOr<SCIP_CONS*> AddSOS1Constraint(
290  const GScipSOSData& sos_data, const std::string& name = "",
292 
293  // Adds the constraint that at most two of the variables in sos_data can be
294  // nonzero, and they must be adjacent under the ordering for sos_data. See
295  // GScipSOSData for details.
296  //
297  // NOTE(user): options.modifiable is ignored (these constraints are not
298  // modifiable).
299  absl::StatusOr<SCIP_CONS*> AddSOS2Constraint(
300  const GScipSOSData& sos_data, const std::string& name = "",
302 
303  // ///////////////////////////////////////////////////////////////////////////
304  // Advanced use
305  // ///////////////////////////////////////////////////////////////////////////
306 
307  // Returns the name of the constraint handler for this constraint.
308  absl::string_view ConstraintType(SCIP_CONS* constraint);
309 
310  // The proposed solution can be partial (only specify some of the variables)
311  // or complete. Complete solutions will be checked for feasibility and
312  // objective quality, and might be unused for these reasons. Partial solutions
313  // will always be accepted.
314  absl::StatusOr<GScipHintResult> SuggestHint(
315  const GScipSolution& partial_solution);
316 
317  // All variables have a default branching priority of zero. Variables are
318  // partitioned by their branching priority, and a fractional variable from the
319  // highest partition will always be branched on.
320  //
321  // TODO(user): Add support for BranchingFactor as well, this is typically
322  // more useful.
323  absl::Status SetBranchingPriority(SCIP_VAR* var, int priority);
324 
325  // Doubles with absolute value of at least this value are replaced by this
326  // value before giving them SCIP. SCIP considers values at least this large to
327  // be infinite. When querying gSCIP, if an absolute value exceeds ScipInf, it
328  // is replaced by std::numeric_limits<double>::infinity().
329  double ScipInf();
330  static constexpr double kDefaultScipInf = 1e20;
331 
332  // WARNING(rander): no synchronization is provided between InterruptSolve()
333  // and ~GScip(). These methods require mutual exclusion, the user is
334  // responsible for ensuring this invariant.
335  // TODO(user): should we add a lock here? Seems a little dangerous to block
336  // in a destructor.
337  bool InterruptSolve();
338 
339  // These should typically not be needed.
340  SCIP* scip() { return scip_; }
341 
342  absl::StatusOr<bool> DefaultBoolParamValue(const std::string& parameter_name);
343  absl::StatusOr<int> DefaultIntParamValue(const std::string& parameter_name);
344  absl::StatusOr<int64_t> DefaultLongParamValue(
345  const std::string& parameter_name);
346  absl::StatusOr<double> DefaultRealParamValue(
347  const std::string& parameter_name);
348  absl::StatusOr<char> DefaultCharParamValue(const std::string& parameter_name);
349  absl::StatusOr<std::string> DefaultStringParamValue(
350  const std::string& parameter_name);
351 
352  private:
353  explicit GScip(SCIP* scip);
354  // Releases SCIP memory.
355  absl::Status CleanUp();
356 
357  absl::Status SetParams(const GScipParameters& params,
358  const std::string& legacy_params);
359  absl::Status FreeTransform();
360  // Clamps d to [-ScipInf(), ScipInf()].
361  double ScipInfClamp(double d);
362  // Returns +/- inf if |d| >= ScipInf(), otherwise returns d.
363  double ScipInfUnclamp(double d);
364 
365  absl::Status MaybeKeepConstraintAlive(SCIP_CONS* constraint,
366  const GScipConstraintOptions& options);
367 
368  SCIP* scip_;
369  absl::flat_hash_set<SCIP_VAR*> variables_;
370  absl::flat_hash_set<SCIP_CONS*> constraints_;
371 };
372 
373 // Advanced features below
374 
375 // Models the constraint
376 // lb <= x * Q * x + a * x <= ub
378  // Models lb above.
379  double lower_bound = -std::numeric_limits<double>::infinity();
380 
381  // Models a * x above. linear_variables and linear_coefficients must have the
382  // same size.
383  std::vector<SCIP_Var*> linear_variables;
384  std::vector<double> linear_coefficients;
385 
386  // These three vectors must have the same size. Models x * Q * x as
387  // sum_i quadratic_coefficients[i] * quadratic_variables1[i]
388  // * quadratic_variables2[i]
389  //
390  // Duplicate quadratic terms (e.g. i=3 encodes 4*x1*x3 and i=4 encodes
391  // 8*x3*x1) are added (as if you added a single entry 12*x1*x3).
392  //
393  // TODO(user): investigate, the documentation seems to suggest that when
394  // linear_variables[i] == quadratic_variables1[i] == quadratic_variables2[i]
395  // there is some advantage.
396  std::vector<SCIP_Var*> quadratic_variables1;
397  std::vector<SCIP_Var*> quadratic_variables2;
398  std::vector<double> quadratic_coefficients;
399 
400  // Models ub above.
401  double upper_bound = std::numeric_limits<double>::infinity();
402 };
403 
404 // Models special ordered set constraints (SOS1 and SOS2 constraints). Each
405 // contains a list of variables that are implicitly ordered by the provided
406 // weights, which must be distinct.
407 // SOS1: At most one of the variables can be nonzero.
408 // SOS2: At most two of the variables can be nonzero, and they must be
409 // consecutive.
410 //
411 // The weights are optional, and if not provided, the ordering in "variables" is
412 // used.
413 struct GScipSOSData {
414  // The list of variables where all but one or two must be zero. Can be integer
415  // or continuous variables, typically their domain will contain zero. Cannot
416  // be empty in a valid SOS constraint.
417  std::vector<SCIP_VAR*> variables;
418 
419  // Optional, can be empty. Otherwise, must have size equal to variables, and
420  // values must be distinct. Determines an "ordering" over the variables
421  // (smallest weight to largest). Additionally, the numeric values of
422  // the weights are used to make branching decisions in a solver specific way,
423  // for details, see:
424  // * https://scip.zib.de/doc/html/cons__sos1_8c.php
425  // * https://scip.zib.de/doc/html/cons__sos2_8c.php.
426  std::vector<double> weights;
427 };
428 
429 // Models the constraint z = 1 => a * x <= b
430 // If negate_indicator, then instead: z = 0 => a * x <= b
432  // The z variable above.
433  SCIP_VAR* indicator_variable = nullptr;
434  bool negate_indicator = false;
435  // The x variable above.
436  std::vector<SCIP_Var*> variables;
437  // a above. Must have the same size as x.
438  std::vector<double> coefficients;
439  // b above.
440  double upper_bound = std::numeric_limits<double>::infinity();
441 };
442 
443 // Data for constraint of the form resultant = f(operators), e.g.:
444 // resultant = AND_i operators[i]
445 // For existing constraints (e.g. AND, OR) resultant and operators[i] should all
446 // be binary variables, this my change. See use in GScip for details.
448  SCIP_VAR* resultant = nullptr;
449  std::vector<SCIP_VAR*> operators;
450 };
451 
452 enum class GScipHintResult {
453  // Hint was not feasible.
454  kInfeasible,
455  // Hint was not good enough to keep.
456  kRejected,
457  // Hint was kept. Partial solutions are not checked for feasibility, they
458  // are always accepted.
459  kAccepted
460 };
461 
462 // Advanced use. Options to use when creating a variable.
464  // ///////////////////////////////////////////////////////////////////////////
465  // SCIP options. Descriptions are from the SCIP documentation, e.g.
466  // SCIPcreateVar:
467  // https://scip.zib.de/doc/html/group__PublicVariableMethods.php#ga7a37fe4dc702dadecc4186b9624e93fc
468  // ///////////////////////////////////////////////////////////////////////////
469 
470  // Should var's column be present in the initial root LP?
471  bool initial = true;
472 
473  // Is var's column removable from the LP (due to aging or cleanup)?
474  bool removable = false;
475 
476  // ///////////////////////////////////////////////////////////////////////////
477  // gSCIP options.
478  // ///////////////////////////////////////////////////////////////////////////
479 
480  // If keep_alive=true, the returned variable will not to be freed until after
481  // ~GScip() is called. Otherwise, the returned variable could be freed
482  // internally by SCIP at any point, and it is not safe to hold a reference to
483  // the returned variable.
484  //
485  // The primary reason to set keep_alive=false is if you are adding many
486  // variables in a callback (in branch and price), and you expect that most of
487  // them will be deleted.
488  bool keep_alive = true;
489 };
490 
491 // Advanced use. Options to use when creating a constraint.
493  // ///////////////////////////////////////////////////////////////////////////
494  // SCIP options. Descriptions are from the SCIP documentation, e.g.
495  // SCIPcreateConsLinear:
496  // https://scip.zib.de/doc/html/group__CONSHDLRS.php#gaea3b4db21fe214be5db047e08b46b50e
497  // ///////////////////////////////////////////////////////////////////////////
498 
499  // Should the LP relaxation of constraint be in the initial LP? False for lazy
500  // constraints (true in callbacks).
501  bool initial = true;
502  // Should the constraint be separated during LP processing?
503  bool separate = true;
504  // Should the constraint be enforced during node processing? True for model
505  // constraints, false for redundant constraints.
506  bool enforce = true;
507  // Should the constraint be checked for feasibility? True for model
508  // constraints, false for redundant constraints.
509  bool check = true;
510  // Should the constraint be propagated during node processing?
511  bool propagate = true;
512  // Is constraint only valid locally? Must be true for branching constraints.
513  bool local = false;
514  // Is constraint modifiable (subject to column generation)? In column
515  // generation applications, set to true if pricing adds coefficients to this
516  // constraint.
517  bool modifiable = false;
518  // Is constraint subject to aging? Set to true for own cuts which are
519  // separated as constraints
520  bool dynamic = false;
521  // Should the relaxation be removed from the LP due to aging or cleanup? Set
522  // to true for 'lazy constraints' and 'user cuts'.
523  bool removable = false;
524  // Should the constraint always be kept at the node where it was added, even
525  // if it may be moved to a more global node? Usually set to false. Set to true
526  // for constraints that represent node data.
527  bool sticking_at_node = false;
528 
529  // ///////////////////////////////////////////////////////////////////////////
530  // gSCIP options.
531  // ///////////////////////////////////////////////////////////////////////////
532 
533  // If keep_alive=true, the returned constraint will not to be freed until
534  // after ~GScip() is called. Otherwise, the returned constraint could be freed
535  // internally by SCIP at any point, and it is not safe to hold a reference to
536  // the returned constraint.
537  //
538  // The primary reason to set keep_alive=false is if you are adding many
539  // constraints in a callback, and you expect that most of them will be
540  // deleted.
541  bool keep_alive = true;
542 };
543 
544 } // namespace operations_research
545 
546 #endif // OR_TOOLS_GSCIP_GSCIP_H_
double LinearConstraintUb(SCIP_CONS *constraint)
Definition: gscip.cc:681
absl::Status SetObjectiveOffset(double offset)
Definition: gscip.cc:558
absl::StatusOr< SCIP_VAR * > AddVariable(double lb, double ub, double obj_coef, GScipVarType var_type, const std::string &var_name="", const GScipVariableOptions &options=DefaultGScipVariableOptions())
Definition: gscip.cc:301
absl::Status DeleteVariable(SCIP_VAR *var)
Definition: gscip.cc:600
absl::StatusOr< SCIP_CONS * > AddOrConstraint(const GScipLogicalConstraintData &logical_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:452
absl::StatusOr< double > DefaultRealParamValue(const std::string &parameter_name)
Definition: gscip.cc:926
absl::Status CanSafeBulkDelete(const absl::flat_hash_set< SCIP_VAR * > &vars)
Definition: gscip.cc:610
absl::StatusOr< SCIP_CONS * > AddAndConstraint(const GScipLogicalConstraintData &logical_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:427
const absl::flat_hash_set< SCIP_CONS * > & constraints()
Definition: gscip.h:195
absl::StatusOr< SCIP_CONS * > AddLinearConstraint(const GScipLinearRange &range, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:333
bool IsConstraintLinear(SCIP_CONS *constraint)
Definition: gscip.cc:661
absl::string_view ConstraintType(SCIP_CONS *constraint)
Definition: gscip.cc:657
absl::StatusOr< int64_t > DefaultLongParamValue(const std::string &parameter_name)
Definition: gscip.cc:918
absl::StatusOr< int > DefaultIntParamValue(const std::string &parameter_name)
Definition: gscip.cc:910
absl::Status DeleteConstraint(SCIP_CONS *constraint)
Definition: gscip.cc:701
absl::Status SetLinearConstraintUb(SCIP_CONS *constraint, double ub)
Definition: gscip.cc:695
absl::Status SafeBulkDelete(const absl::flat_hash_set< SCIP_VAR * > &vars)
Definition: gscip.cc:621
static absl::StatusOr< std::unique_ptr< GScip > > Create(const std::string &problem_name)
Definition: gscip.cc:248
double Ub(SCIP_VAR *var)
Definition: gscip.cc:645
double ObjCoef(SCIP_VAR *var)
Definition: gscip.cc:649
absl::Status SetMaximize(bool is_maximize)
Definition: gscip.cc:552
absl::Span< SCIP_VAR *const > LinearConstraintVariables(SCIP_CONS *constraint)
Definition: gscip.cc:671
absl::StatusOr< std::string > DefaultStringParamValue(const std::string &parameter_name)
Definition: gscip.cc:942
absl::StatusOr< bool > DefaultBoolParamValue(const std::string &parameter_name)
Definition: gscip.cc:902
absl::StatusOr< SCIP_CONS * > AddIndicatorConstraint(const GScipIndicatorConstraint &indicator_constraint, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:393
double Lb(SCIP_VAR *var)
Definition: gscip.cc:641
const absl::flat_hash_set< SCIP_VAR * > & variables()
Definition: gscip.h:190
absl::Status SetLb(SCIP_VAR *var, double lb)
Definition: gscip.cc:576
double LinearConstraintLb(SCIP_CONS *constraint)
Definition: gscip.cc:677
absl::Status SetLinearConstraintCoef(SCIP_CONS *constraint, SCIP_VAR *var, double value)
Definition: gscip.cc:708
absl::Status SetLinearConstraintLb(SCIP_CONS *constraint, double lb)
Definition: gscip.cc:689
absl::StatusOr< GScipHintResult > SuggestHint(const GScipSolution &partial_solution)
Definition: gscip.cc:717
absl::StatusOr< GScipResult > Solve(const GScipParameters &params=GScipParameters(), const std::string &legacy_params="", GScipMessageHandler message_handler=nullptr)
Definition: gscip.cc:754
GScipVarType VarType(SCIP_VAR *var)
Definition: gscip.cc:651
absl::Status SetVarType(SCIP_VAR *var, GScipVarType var_type)
Definition: gscip.cc:593
absl::Status SetBranchingPriority(SCIP_VAR *var, int priority)
Definition: gscip.cc:571
absl::StatusOr< char > DefaultCharParamValue(const std::string &parameter_name)
Definition: gscip.cc:934
absl::Span< const double > LinearConstraintCoefficients(SCIP_CONS *constraint)
Definition: gscip.cc:665
absl::Status SetUb(SCIP_VAR *var, double ub)
Definition: gscip.cc:582
absl::Status SetObjCoef(SCIP_VAR *var, double obj_coef)
Definition: gscip.cc:588
absl::StatusOr< SCIP_CONS * > AddSOS2Constraint(const GScipSOSData &sos_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:526
static std::string ScipVersion()
Definition: gscip.cc:266
absl::StatusOr< SCIP_CONS * > AddQuadraticConstraint(const GScipQuadraticRange &range, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:359
static constexpr double kDefaultScipInf
Definition: gscip.h:330
absl::string_view Name(SCIP_VAR *var)
Definition: gscip.cc:655
absl::StatusOr< SCIP_CONS * > AddSOS1Constraint(const GScipSOSData &sos_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:499
const std::string name
int64_t value
IntVar * var
Definition: expr_array.cc:1874
Collection of objects used to extend the Constraint Solver library.
const GScipConstraintOptions & DefaultGScipConstraintOptions()
Definition: gscip.cc:180
std::function< void(GScipMessageType type, absl::string_view message)> GScipMessageHandler
const GScipVariableOptions & DefaultGScipVariableOptions()
Definition: gscip.cc:175
absl::flat_hash_map< SCIP_VAR *, int > GScipBranchingPriority
Definition: gscip.h:121
absl::flat_hash_map< SCIP_VAR *, double > GScipSolution
Definition: gscip.h:74
std::vector< SCIP_Var * > variables
Definition: gscip.h:436
std::vector< SCIP_VAR * > variables
Definition: gscip.h:100
std::vector< double > coefficients
Definition: gscip.h:101
std::vector< SCIP_VAR * > operators
Definition: gscip.h:449
std::vector< SCIP_Var * > quadratic_variables1
Definition: gscip.h:396
std::vector< SCIP_Var * > quadratic_variables2
Definition: gscip.h:397
std::vector< SCIP_Var * > linear_variables
Definition: gscip.h:383
std::vector< double > linear_coefficients
Definition: gscip.h:384
std::vector< double > quadratic_coefficients
Definition: gscip.h:398
absl::flat_hash_map< SCIP_VAR *, double > primal_ray
Definition: gscip.h:90
std::vector< double > objective_values
Definition: gscip.h:85
std::vector< GScipSolution > solutions
Definition: gscip.h:83
std::vector< SCIP_VAR * > variables
Definition: gscip.h:417
std::vector< double > weights
Definition: gscip.h:426