OR-Tools  9.3
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// but < inf result in an error. Changing the underlying SCIP's infinity is
27// 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
72namespace operations_research {
73
74using 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.
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
110struct GScipIndicatorConstraint;
111struct GScipLogicalConstraintData;
112// Some advanced features, defined at the end of the header file.
113struct GScipQuadraticRange;
114struct GScipSOSData;
115struct GScipVariableOptions;
116
117const GScipVariableOptions& DefaultGScipVariableOptions();
118struct GScipConstraintOptions;
119
120const GScipConstraintOptions& DefaultGScipConstraintOptions();
121using GScipBranchingPriority = absl::flat_hash_map<SCIP_VAR*, int>;
122enum 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.
127class 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 absl::Status AddLinearConstraintCoef(SCIP_CONS* constraint, SCIP_VAR* var,
237 double value);
238
239 // Works on all constraint types. Unlike DeleteVariable, no special action is
240 // required before deleting a constraint.
241 absl::Status DeleteConstraint(SCIP_CONS* constraint);
242
243 // ///////////////////////////////////////////////////////////////////////////
244 // Nonlinear constraint types.
245 // For now, only basic support (adding to the model) is provided. Reading and
246 // updating support may be added in the future.
247 // ///////////////////////////////////////////////////////////////////////////
248
249 // Adds a constraint of the form:
250 // if z then a * x <= b
251 // where z is a binary variable, x is a vector of decision variables, a is
252 // vector of constants, and b is a constant. z can be negated.
253 //
254 // NOTE(user): options.modifiable is ignored.
255 absl::StatusOr<SCIP_CONS*> AddIndicatorConstraint(
256 const GScipIndicatorConstraint& indicator_constraint,
257 const std::string& name = "",
259
260 // Adds a constraint of form lb <= x * Q * x + a * x <= ub.
261 //
262 // NOTE(user): options.modifiable and options.sticking_at_node are ignored.
263 absl::StatusOr<SCIP_CONS*> AddQuadraticConstraint(
264 const GScipQuadraticRange& range, const std::string& name = "",
266
267 // Adds the constraint:
268 // logical_data.resultant = AND_i logical_data.operators[i],
269 // where logical_data.resultant and logical_data.operators[i] are all binary
270 // variables.
271 absl::StatusOr<SCIP_CONS*> AddAndConstraint(
272 const GScipLogicalConstraintData& logical_data,
273 const std::string& name = "",
275
276 // Adds the constraint:
277 // logical_data.resultant = OR_i logical_data.operators[i],
278 // where logical_data.resultant and logical_data.operators[i] must be binary
279 // variables.
280 absl::StatusOr<SCIP_CONS*> AddOrConstraint(
281 const GScipLogicalConstraintData& logical_data,
282 const std::string& name = "",
284
285 // Adds the constraint that at most one of the variables in sos_data can be
286 // nonzero. The variables can be integer or continuous. See GScipSOSData for
287 // details.
288 //
289 // NOTE(user): options.modifiable is ignored (these constraints are not
290 // modifiable).
291 absl::StatusOr<SCIP_CONS*> AddSOS1Constraint(
292 const GScipSOSData& sos_data, const std::string& name = "",
294
295 // Adds the constraint that at most two of the variables in sos_data can be
296 // nonzero, and they must be adjacent under the ordering for sos_data. See
297 // GScipSOSData for details.
298 //
299 // NOTE(user): options.modifiable is ignored (these constraints are not
300 // modifiable).
301 absl::StatusOr<SCIP_CONS*> AddSOS2Constraint(
302 const GScipSOSData& sos_data, const std::string& name = "",
304
305 // ///////////////////////////////////////////////////////////////////////////
306 // Advanced use
307 // ///////////////////////////////////////////////////////////////////////////
308
309 // Returns the name of the constraint handler for this constraint.
310 absl::string_view ConstraintType(SCIP_CONS* constraint);
311
312 // The proposed solution can be partial (only specify some of the variables)
313 // or complete. Complete solutions will be checked for feasibility and
314 // objective quality, and might be unused for these reasons. Partial solutions
315 // will always be accepted.
316 absl::StatusOr<GScipHintResult> SuggestHint(
317 const GScipSolution& partial_solution);
318
319 // All variables have a default branching priority of zero. Variables are
320 // partitioned by their branching priority, and a fractional variable from the
321 // highest partition will always be branched on.
322 //
323 // TODO(user): Add support for BranchingFactor as well, this is typically
324 // more useful.
325 absl::Status SetBranchingPriority(SCIP_VAR* var, int priority);
326
327 // Doubles with absolute value of at least this value are invalid and result
328 // in errors. Floating point actual infinities are replaced by this value in
329 // SCIP calls. SCIP considers values at least this large to be infinite. When
330 // querying gSCIP, if an absolute value exceeds ScipInf, it is replaced by
331 // std::numeric_limits<double>::infinity().
332 double ScipInf();
333 static constexpr double kDefaultScipInf = 1e20;
334
335 // WARNING(rander): no synchronization is provided between InterruptSolve()
336 // and ~GScip(). These methods require mutual exclusion, the user is
337 // responsible for ensuring this invariant.
338 // TODO(user): should we add a lock here? Seems a little dangerous to block
339 // in a destructor.
340 bool InterruptSolve();
341
342 // These should typically not be needed.
343 SCIP* scip() { return scip_; }
344
345 absl::StatusOr<bool> DefaultBoolParamValue(const std::string& parameter_name);
346 absl::StatusOr<int> DefaultIntParamValue(const std::string& parameter_name);
347 absl::StatusOr<int64_t> DefaultLongParamValue(
348 const std::string& parameter_name);
349 absl::StatusOr<double> DefaultRealParamValue(
350 const std::string& parameter_name);
351 absl::StatusOr<char> DefaultCharParamValue(const std::string& parameter_name);
352 absl::StatusOr<std::string> DefaultStringParamValue(
353 const std::string& parameter_name);
354
355 private:
356 explicit GScip(SCIP* scip);
357 // Releases SCIP memory.
358 absl::Status CleanUp();
359
360 absl::Status SetParams(const GScipParameters& params,
361 const std::string& legacy_params);
362 absl::Status FreeTransform();
363 // Replaces +/- inf by +/- ScipInf(), fails when |d| is in [ScipInf(), inf).
364 absl::StatusOr<double> ScipInfClamp(double d);
365 // Returns +/- inf if |d| >= ScipInf(), otherwise returns d.
366 double ScipInfUnclamp(double d);
367
368 absl::Status MaybeKeepConstraintAlive(SCIP_CONS* constraint,
369 const GScipConstraintOptions& options);
370
371 SCIP* scip_;
372 absl::flat_hash_set<SCIP_VAR*> variables_;
373 absl::flat_hash_set<SCIP_CONS*> constraints_;
374};
375
376// Advanced features below
377
378// Models the constraint
379// lb <= x * Q * x + a * x <= ub
381 // Models lb above.
382 double lower_bound = -std::numeric_limits<double>::infinity();
383
384 // Models a * x above. linear_variables and linear_coefficients must have the
385 // same size.
386 std::vector<SCIP_Var*> linear_variables;
387 std::vector<double> linear_coefficients;
388
389 // These three vectors must have the same size. Models x * Q * x as
390 // sum_i quadratic_coefficients[i] * quadratic_variables1[i]
391 // * quadratic_variables2[i]
392 //
393 // Duplicate quadratic terms (e.g. i=3 encodes 4*x1*x3 and i=4 encodes
394 // 8*x3*x1) are added (as if you added a single entry 12*x1*x3).
395 //
396 // TODO(user): investigate, the documentation seems to suggest that when
397 // linear_variables[i] == quadratic_variables1[i] == quadratic_variables2[i]
398 // there is some advantage.
399 std::vector<SCIP_Var*> quadratic_variables1;
400 std::vector<SCIP_Var*> quadratic_variables2;
401 std::vector<double> quadratic_coefficients;
402
403 // Models ub above.
404 double upper_bound = std::numeric_limits<double>::infinity();
405};
406
407// Models special ordered set constraints (SOS1 and SOS2 constraints). Each
408// contains a list of variables that are implicitly ordered by the provided
409// weights, which must be distinct.
410// SOS1: At most one of the variables can be nonzero.
411// SOS2: At most two of the variables can be nonzero, and they must be
412// consecutive.
413//
414// The weights are optional, and if not provided, the ordering in "variables" is
415// used.
417 // The list of variables where all but one or two must be zero. Can be integer
418 // or continuous variables, typically their domain will contain zero. Cannot
419 // be empty in a valid SOS constraint.
420 std::vector<SCIP_VAR*> variables;
421
422 // Optional, can be empty. Otherwise, must have size equal to variables, and
423 // values must be distinct. Determines an "ordering" over the variables
424 // (smallest weight to largest). Additionally, the numeric values of
425 // the weights are used to make branching decisions in a solver specific way,
426 // for details, see:
427 // * https://scip.zib.de/doc/html/cons__sos1_8c.php
428 // * https://scip.zib.de/doc/html/cons__sos2_8c.php.
429 std::vector<double> weights;
430};
431
432// Models the constraint z = 1 => a * x <= b
433// If negate_indicator, then instead: z = 0 => a * x <= b
435 // The z variable above.
436 SCIP_VAR* indicator_variable = nullptr;
437 bool negate_indicator = false;
438 // The x variable above.
439 std::vector<SCIP_Var*> variables;
440 // a above. Must have the same size as x.
441 std::vector<double> coefficients;
442 // b above.
443 double upper_bound = std::numeric_limits<double>::infinity();
444};
445
446// Data for constraint of the form resultant = f(operators), e.g.:
447// resultant = AND_i operators[i]
448// For existing constraints (e.g. AND, OR) resultant and operators[i] should all
449// be binary variables, this my change. See use in GScip for details.
451 SCIP_VAR* resultant = nullptr;
452 std::vector<SCIP_VAR*> operators;
453};
454
455enum class GScipHintResult {
456 // Hint was not feasible.
458 // Hint was not good enough to keep.
459 kRejected,
460 // Hint was kept. Partial solutions are not checked for feasibility, they
461 // are always accepted.
463};
464
465// Advanced use. Options to use when creating a variable.
467 // ///////////////////////////////////////////////////////////////////////////
468 // SCIP options. Descriptions are from the SCIP documentation, e.g.
469 // SCIPcreateVar:
470 // https://scip.zib.de/doc/html/group__PublicVariableMethods.php#ga7a37fe4dc702dadecc4186b9624e93fc
471 // ///////////////////////////////////////////////////////////////////////////
472
473 // Should var's column be present in the initial root LP?
474 bool initial = true;
475
476 // Is var's column removable from the LP (due to aging or cleanup)?
477 bool removable = false;
478
479 // ///////////////////////////////////////////////////////////////////////////
480 // gSCIP options.
481 // ///////////////////////////////////////////////////////////////////////////
482
483 // If keep_alive=true, the returned variable will not to be freed until after
484 // ~GScip() is called. Otherwise, the returned variable could be freed
485 // internally by SCIP at any point, and it is not safe to hold a reference to
486 // the returned variable.
487 //
488 // The primary reason to set keep_alive=false is if you are adding many
489 // variables in a callback (in branch and price), and you expect that most of
490 // them will be deleted.
491 bool keep_alive = true;
492};
493
494// Advanced use. Options to use when creating a constraint.
496 // ///////////////////////////////////////////////////////////////////////////
497 // SCIP options. Descriptions are from the SCIP documentation, e.g.
498 // SCIPcreateConsLinear:
499 // https://scip.zib.de/doc/html/group__CONSHDLRS.php#gaea3b4db21fe214be5db047e08b46b50e
500 // ///////////////////////////////////////////////////////////////////////////
501
502 // Should the LP relaxation of constraint be in the initial LP? False for lazy
503 // constraints (true in callbacks).
504 bool initial = true;
505 // Should the constraint be separated during LP processing?
506 bool separate = true;
507 // Should the constraint be enforced during node processing? True for model
508 // constraints, false for redundant constraints.
509 bool enforce = true;
510 // Should the constraint be checked for feasibility? True for model
511 // constraints, false for redundant constraints.
512 bool check = true;
513 // Should the constraint be propagated during node processing?
514 bool propagate = true;
515 // Is constraint only valid locally? Must be true for branching constraints.
516 bool local = false;
517 // Is constraint modifiable (subject to column generation)? In column
518 // generation applications, set to true if pricing adds coefficients to this
519 // constraint.
520 bool modifiable = false;
521 // Is constraint subject to aging? Set to true for own cuts which are
522 // separated as constraints
523 bool dynamic = false;
524 // Should the relaxation be removed from the LP due to aging or cleanup? Set
525 // to true for 'lazy constraints' and 'user cuts'.
526 bool removable = false;
527 // Should the constraint always be kept at the node where it was added, even
528 // if it may be moved to a more global node? Usually set to false. Set to true
529 // for constraints that represent node data.
530 bool sticking_at_node = false;
531
532 // ///////////////////////////////////////////////////////////////////////////
533 // gSCIP options.
534 // ///////////////////////////////////////////////////////////////////////////
535
536 // If keep_alive=true, the returned constraint will not to be freed until
537 // after ~GScip() is called. Otherwise, the returned constraint could be freed
538 // internally by SCIP at any point, and it is not safe to hold a reference to
539 // the returned constraint.
540 //
541 // The primary reason to set keep_alive=false is if you are adding many
542 // constraints in a callback, and you expect that most of them will be
543 // deleted.
544 bool keep_alive = true;
545};
546
547} // namespace operations_research
548
549#endif // OR_TOOLS_GSCIP_GSCIP_H_
double LinearConstraintUb(SCIP_CONS *constraint)
Definition: gscip.cc:717
absl::Status SetObjectiveOffset(double offset)
Definition: gscip.cc:594
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:326
absl::Status DeleteVariable(SCIP_VAR *var)
Definition: gscip.cc:636
absl::StatusOr< SCIP_CONS * > AddOrConstraint(const GScipLogicalConstraintData &logical_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:488
absl::StatusOr< double > DefaultRealParamValue(const std::string &parameter_name)
Definition: gscip.cc:979
absl::Status CanSafeBulkDelete(const absl::flat_hash_set< SCIP_VAR * > &vars)
Definition: gscip.cc:646
absl::StatusOr< SCIP_CONS * > AddAndConstraint(const GScipLogicalConstraintData &logical_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:463
absl::StatusOr< SCIP_CONS * > AddLinearConstraint(const GScipLinearRange &range, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:358
bool IsConstraintLinear(SCIP_CONS *constraint)
Definition: gscip.cc:697
absl::string_view ConstraintType(SCIP_CONS *constraint)
Definition: gscip.cc:693
absl::StatusOr< int64_t > DefaultLongParamValue(const std::string &parameter_name)
Definition: gscip.cc:971
absl::StatusOr< int > DefaultIntParamValue(const std::string &parameter_name)
Definition: gscip.cc:963
absl::Status DeleteConstraint(SCIP_CONS *constraint)
Definition: gscip.cc:737
absl::Status SetLinearConstraintUb(SCIP_CONS *constraint, double ub)
Definition: gscip.cc:731
absl::Status SafeBulkDelete(const absl::flat_hash_set< SCIP_VAR * > &vars)
Definition: gscip.cc:657
const absl::flat_hash_set< SCIP_VAR * > & variables()
Definition: gscip.h:190
static absl::StatusOr< std::unique_ptr< GScip > > Create(const std::string &problem_name)
Definition: gscip.cc:273
double Ub(SCIP_VAR *var)
Definition: gscip.cc:681
double ObjCoef(SCIP_VAR *var)
Definition: gscip.cc:685
absl::Status SetMaximize(bool is_maximize)
Definition: gscip.cc:588
absl::StatusOr< std::string > DefaultStringParamValue(const std::string &parameter_name)
Definition: gscip.cc:995
absl::StatusOr< bool > DefaultBoolParamValue(const std::string &parameter_name)
Definition: gscip.cc:955
absl::StatusOr< SCIP_CONS * > AddIndicatorConstraint(const GScipIndicatorConstraint &indicator_constraint, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:426
double Lb(SCIP_VAR *var)
Definition: gscip.cc:677
absl::Status SetLb(SCIP_VAR *var, double lb)
Definition: gscip.cc:612
absl::Span< SCIP_VAR *const > LinearConstraintVariables(SCIP_CONS *constraint)
Definition: gscip.cc:707
double LinearConstraintLb(SCIP_CONS *constraint)
Definition: gscip.cc:713
absl::Status SetLinearConstraintCoef(SCIP_CONS *constraint, SCIP_VAR *var, double value)
Definition: gscip.cc:744
absl::Status SetLinearConstraintLb(SCIP_CONS *constraint, double lb)
Definition: gscip.cc:725
absl::StatusOr< GScipHintResult > SuggestHint(const GScipSolution &partial_solution)
Definition: gscip.cc:760
absl::StatusOr< GScipResult > Solve(const GScipParameters &params=GScipParameters(), const std::string &legacy_params="", GScipMessageHandler message_handler=nullptr)
Definition: gscip.cc:797
GScipVarType VarType(SCIP_VAR *var)
Definition: gscip.cc:687
absl::Status SetVarType(SCIP_VAR *var, GScipVarType var_type)
Definition: gscip.cc:629
absl::Status SetBranchingPriority(SCIP_VAR *var, int priority)
Definition: gscip.cc:607
absl::StatusOr< char > DefaultCharParamValue(const std::string &parameter_name)
Definition: gscip.cc:987
absl::Span< const double > LinearConstraintCoefficients(SCIP_CONS *constraint)
Definition: gscip.cc:701
absl::Status SetUb(SCIP_VAR *var, double ub)
Definition: gscip.cc:618
absl::Status SetObjCoef(SCIP_VAR *var, double obj_coef)
Definition: gscip.cc:624
absl::StatusOr< SCIP_CONS * > AddSOS2Constraint(const GScipSOSData &sos_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:562
static std::string ScipVersion()
Definition: gscip.cc:291
absl::StatusOr< SCIP_CONS * > AddQuadraticConstraint(const GScipQuadraticRange &range, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:388
const absl::flat_hash_set< SCIP_CONS * > & constraints()
Definition: gscip.h:195
static constexpr double kDefaultScipInf
Definition: gscip.h:333
absl::string_view Name(SCIP_VAR *var)
Definition: gscip.cc:691
absl::Status AddLinearConstraintCoef(SCIP_CONS *constraint, SCIP_VAR *var, double value)
Definition: gscip.cc:753
absl::StatusOr< SCIP_CONS * > AddSOS1Constraint(const GScipSOSData &sos_data, const std::string &name="", const GScipConstraintOptions &options=DefaultGScipConstraintOptions())
Definition: gscip.cc:535
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:205
std::function< void(GScipMessageType type, absl::string_view message)> GScipMessageHandler
const GScipVariableOptions & DefaultGScipVariableOptions()
Definition: gscip.cc:200
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:439
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:452
std::vector< SCIP_Var * > quadratic_variables1
Definition: gscip.h:399
std::vector< SCIP_Var * > quadratic_variables2
Definition: gscip.h:400
std::vector< SCIP_Var * > linear_variables
Definition: gscip.h:386
std::vector< double > linear_coefficients
Definition: gscip.h:387
std::vector< double > quadratic_coefficients
Definition: gscip.h:401
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:420
std::vector< double > weights
Definition: gscip.h:429