1// Copyright 2010-2025 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
6// http://www.apache.org/licenses/LICENSE-2.0
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.
14// Proto describing a general Constraint Programming (CP) problem.
18package operations_research.sat;
20option csharp_namespace = "Google.OrTools.Sat";
21option go_package = "github.com/google/or-tools/ortools/sat/proto/cpmodel";
22option java_package = "com.google.ortools.sat";
23option java_multiple_files = true;
24option java_outer_classname = "CpModelProtobuf";
26// An integer variable.
28// It will be referred to by an int32 corresponding to its index in a
29// CpModelProto variables field.
31// Depending on the context, a reference to a variable whose domain is in [0, 1]
32// can also be seen as a Boolean that will be true if the variable value is 1
33// and false if it is 0. When used in this context, the field name will always
34// contain the word "literal".
36// Negative reference (advanced usage): to simplify the creation of a model and
37// for efficiency reasons, all the "literal" or "variable" fields can also
38// contain a negative index. A negative index i will refer to the negation of
39// the integer variable at index -i -1 or to NOT the literal at the same index.
41// Ex: A variable index 4 will refer to the integer variable model.variables(4)
42// and an index of -5 will refer to the negation of the same variable. A literal
43// index 4 will refer to the logical fact that model.variable(4) == 1 and a
44// literal index of -5 will refer to the logical fact model.variable(4) == 0.
45message IntegerVariableProto {
46 // For debug/logging only. Can be empty.
49 // The variable domain given as a sorted list of n disjoint intervals
50 // [min, max] and encoded as [min_0, max_0, ..., min_{n-1}, max_{n-1}].
52 // The most common example being just [min, max].
53 // If min == max, then this is a constant variable.
56 // - domain_size() is always even.
57 // - min == domain.front();
58 // - max == domain.back();
59 // - for all i < n : min_i <= max_i
60 // - for all i < n-1 : max_i + 1 < min_{i+1}.
62 // Note that we check at validation that a variable domain is small enough so
63 // that we don't run into integer overflow in our algorithms. Because of that,
64 // you cannot just have "unbounded" variable like [0, kint64max] and should
65 // try to specify tighter domains.
66 repeated int64 domain = 2;
69// Argument of the constraints of the form OP(literals).
70message BoolArgumentProto {
71 repeated int32 literals = 1;
74// Some constraints supports linear expression instead of just using a reference
75// to a variable. This is especially useful during presolve to reduce the model
77message LinearExpressionProto {
78 repeated int32 vars = 1;
79 repeated int64 coeffs = 2;
83message LinearArgumentProto {
84 LinearExpressionProto target = 1;
85 repeated LinearExpressionProto exprs = 2;
88// All expressions must take different values.
89message AllDifferentConstraintProto {
90 repeated LinearExpressionProto exprs = 1;
93// The linear sum vars[i] * coeffs[i] must fall in the given domain. The domain
94// has the same format as the one in IntegerVariableProto.
96// Note that the validation code currently checks using the domain of the
97// involved variables that the sum can always be computed without integer
98// overflow and throws an error otherwise.
99message LinearConstraintProto {
100 repeated int32 vars = 1;
101 repeated int64 coeffs = 2; // Same size as vars.
102 repeated int64 domain = 3;
105// The constraint linear_target = exprs[linear_index].
106// This enforces that index takes one of the value in [0, vars_size()).
107message ElementConstraintProto {
108 int32 index = 1; // Legacy field.
109 int32 target = 2; // Legacy field.
110 repeated int32 vars = 3; // Legacy field.
111 LinearExpressionProto linear_index = 4;
112 LinearExpressionProto linear_target = 5;
113 repeated LinearExpressionProto exprs = 6;
116// This is not really a constraint. It is there so it can be referred by other
117// constraints using this "interval" concept.
119// IMPORTANT: For now, this constraint do not enforce any relations on the
120// components, and it is up to the client to add in the model:
121// - enforcement => start + size == end.
122// - enforcement => size >= 0 // Only needed if size is not already >= 0.
123message IntervalConstraintProto {
124 LinearExpressionProto start = 4;
125 LinearExpressionProto end = 5;
126 LinearExpressionProto size = 6;
129// All the intervals (index of IntervalConstraintProto) must be disjoint. More
130// formally, there must exist a sequence so that for each consecutive intervals,
131// we have end_i <= start_{i+1}. In particular, intervals of size zero do matter
132// for this constraint. This is also known as a disjunctive constraint in
134message NoOverlapConstraintProto {
135 repeated int32 intervals = 1;
138// The boxes defined by [start_x, end_x) * [start_y, end_y) cannot overlap.
139// Furthermore, one box is optional if at least one of the x or y interval is
142// Note that the case of boxes of size zero is special. The following cases
143// violate the constraint:
144// - a point box inside a box with a non zero area
145// - a line box overlapping a box with a non zero area
146// - one vertical line box crossing an horizontal line box.
147message NoOverlap2DConstraintProto {
148 repeated int32 x_intervals = 1;
149 repeated int32 y_intervals = 2; // Same size as x_intervals.
152// The sum of the demands of the intervals at each interval point cannot exceed
153// a capacity. Note that intervals are interpreted as [start, end) and as
154// such intervals like [2,3) and [3,4) do not overlap for the point of view of
155// this constraint. Moreover, intervals of size zero are ignored.
157// All demands must not contain any negative value in their domains. This is
158// checked at validation. Even if there are no intervals, this constraint
159// implicit enforces capacity >= 0. In other words, a negative capacity is
160// considered valid but always infeasible.
161message CumulativeConstraintProto {
162 LinearExpressionProto capacity = 1;
163 repeated int32 intervals = 2;
164 repeated LinearExpressionProto demands = 3; // Same size as intervals.
167// Maintain a reservoir level within bounds. The water level starts at 0, and at
168// any time, it must be within [min_level, max_level].
170// If the variable active_literals[i] is true, and if the expression
171// time_exprs[i] is assigned a value t, then the current level changes by
172// level_changes[i] at the time t. Therefore, at any time t:
174// sum(level_changes[i] * active_literals[i] if time_exprs[i] <= t)
175// in [min_level, max_level]
177// Note that min level must be <= 0, and the max level must be >= 0. Please use
178// fixed level_changes to simulate initial state.
180// The array of boolean variables 'actives', if defined, indicates which actions
181// are actually performed. If this array is not defined, then it is assumed that
182// all actions will be performed.
183message ReservoirConstraintProto {
186 repeated LinearExpressionProto time_exprs = 3;
187 repeated LinearExpressionProto level_changes = 6;
188 repeated int32 active_literals = 5;
192// The circuit constraint is defined on a graph where the arc presence are
193// controlled by literals. Each arc is given by an index in the
194// tails/heads/literals lists that must have the same size.
196// For now, we ignore node indices with no incident arc. All the other nodes
197// must have exactly one incoming and one outgoing selected arc (i.e. literal at
198// true). All the selected arcs that are not self-loops must form a single
199// circuit. Note that multi-arcs are allowed, but only one of them will be true
200// at the same time. Multi-self loop are disallowed though.
201message CircuitConstraintProto {
202 repeated int32 tails = 3;
203 repeated int32 heads = 4;
204 repeated int32 literals = 5;
207// The "VRP" (Vehicle Routing Problem) constraint.
209// The direct graph where arc #i (from tails[i] to head[i]) is present iff
210// literals[i] is true must satisfy this set of properties:
211// - #incoming arcs == 1 except for node 0.
212// - #outgoing arcs == 1 except for node 0.
213// - for node zero, #incoming arcs == #outgoing arcs.
214// - There are no duplicate arcs.
215// - Self-arcs are allowed except for node 0.
216// - There is no cycle in this graph, except through node 0.
218// Note: Currently this constraint expects all the nodes in [0, num_nodes) to
219// have at least one incident arc. The model will be considered invalid if it
220// is not the case. You can add self-arc fixed to one to ignore some nodes if
223// TODO(user): It is probably possible to generalize this constraint to a
224// no-cycle in a general graph, or a no-cycle with sum incoming <= 1 and sum
225// outgoing <= 1 (more efficient implementation). On the other hand, having this
226// specific constraint allow us to add specific "cuts" to a VRP problem.
227message RoutesConstraintProto {
228 repeated int32 tails = 1;
229 repeated int32 heads = 2;
230 repeated int32 literals = 3;
232 // DEPRECATED. These fields are no longer used. The solver ignores them.
233 repeated int32 demands = 4;
236 // A set of linear expressions associated with the nodes.
237 message NodeExpressions {
238 // The i-th element is the linear expression associated with the i-th node.
239 repeated LinearExpressionProto exprs = 1;
242 // Expressions associated with the nodes of the graph, such as the load of the
243 // vehicle arriving at a node, or the time at which a vehicle arrives at a
244 // node. Expressions with the same "dimension" (such as "load" or "time") must
245 // be listed together.
246 // This field is optional. If it is set, the linear constraints of size 1 or 2
247 // between the variables in these expressions will be used to derive cuts for
248 // this constraint. If it is not set, the solver will try to automatically
249 // derive it, from the linear constraints of size 1 or 2 in the model (this
250 // can fail in complex cases).
251 repeated NodeExpressions dimensions = 6;
254// The values of the n-tuple formed by the given expression can only be one of
255// the listed n-tuples in values. The n-tuples are encoded in a flattened way:
256// [tuple0_v0, tuple0_v1, ..., tuple0_v{n-1}, tuple1_v0, ...].
258// - If all `vars`, `values` and `exprs` are empty, the constraint is trivially
259// true, irrespective of the value of `negated`.
260// - If `values` is empty but either vars or exprs is not, the constraint is
261// trivially false if `negated` is false, and trivially true if `negated` is
263// - If `vars` and `exprs` are empty but `values` is not, the model is invalid.
264message TableConstraintProto {
265 repeated int32 vars = 1; // Legacy field.
266 repeated int64 values = 2;
267 repeated LinearExpressionProto exprs = 4;
269 // If true, the meaning is "negated", that is we forbid any of the given
270 // tuple from a feasible assignment.
274// The two arrays of variable each represent a function, the second is the
275// inverse of the first: f_direct[i] == j <=> f_inverse[j] == i.
276message InverseConstraintProto {
277 repeated int32 f_direct = 1;
278 repeated int32 f_inverse = 2;
281// This constraint forces a sequence of expressions to be accepted by an
283message AutomatonConstraintProto {
284 // A state is identified by a non-negative number. It is preferable to keep
285 // all the states dense in says [0, num_states). The automaton starts at
286 // starting_state and must finish in any of the final states.
287 int64 starting_state = 2;
288 repeated int64 final_states = 3;
290 // List of transitions (all 3 vectors have the same size). Both tail and head
291 // are states, label is any variable value. No two outgoing transitions from
292 // the same state can have the same label.
293 repeated int64 transition_tail = 4;
294 repeated int64 transition_head = 5;
295 repeated int64 transition_label = 6;
298 repeated int32 vars = 7;
299 // The sequence of expressions. The automaton is ran for exprs_size() "steps"
300 // and the value of exprs[i] corresponds to the transition label at step i.
301 repeated LinearExpressionProto exprs = 8;
304// A list of variables, without any semantics.
305message ListOfVariablesProto {
306 repeated int32 vars = 1;
310message ConstraintProto {
311 // For debug/logging only. Can be empty.
314 // The constraint will be enforced iff all literals listed here are true. If
315 // this is empty, then the constraint will always be enforced. An enforced
316 // constraint must be satisfied, and an un-enforced one will simply be
319 // This is also called half-reification. To have an equivalence between a
320 // literal and a constraint (full reification), one must add both a constraint
321 // (controlled by a literal l) and its negation (controlled by the negation of
324 // Important: as of September 2025, some constraints might be less efficient
325 // with enforcement than without: circuit, routes, no_overlap, no_overlap_2d,
326 // and cumulative. If performance is not great, consider using a model without
327 // these constraints enforced.
328 repeated int32 enforcement_literal = 2;
330 // The actual constraint with its arguments.
332 // The bool_or constraint forces at least one literal to be true.
333 BoolArgumentProto bool_or = 3;
335 // The bool_and constraint forces all of the literals to be true.
337 // This is a "redundant" constraint in the sense that this can easily be
338 // encoded with many bool_or or at_most_one. It is just more space efficient
339 // and handled slightly differently internally.
340 BoolArgumentProto bool_and = 4;
342 // The at_most_one constraint enforces that no more than one literal is
343 // true at the same time.
345 // Note that an at most one constraint of length n could be encoded with n
346 // bool_and constraint with n-1 term on the right hand side. So in a sense,
347 // this constraint contribute directly to the "implication-graph" or the
348 // 2-SAT part of the model.
349 BoolArgumentProto at_most_one = 26;
351 // The exactly_one constraint force exactly one literal to true and no more.
353 // Anytime a bool_or (it could have been called at_least_one) is included
354 // into an at_most_one, then the bool_or is actually an exactly one
355 // constraint, and the extra literal in the at_most_one can be set to false.
356 // So in this sense, this constraint is not really needed. it is just here
357 // for a better description of the problem structure and to facilitate some
359 BoolArgumentProto exactly_one = 29;
361 // The bool_xor constraint forces an odd number of the literals to be true.
362 BoolArgumentProto bool_xor = 5;
364 // The int_div constraint forces the target to equal exprs[0] / exprs[1].
365 // The division is "rounded" towards zero, so we can have for instance
366 // (2 = 12 / 5) or (-3 = -10 / 3). If you only want exact integer division,
367 // then you should use instead of t = a / b, the int_prod constraint
370 // If 0 belongs to the domain of exprs[1], then the model is deemed invalid.
371 LinearArgumentProto int_div = 7;
373 // The int_mod constraint forces the target to equal exprs[0] % exprs[1].
374 // The domain of exprs[1] must be strictly positive. The sign of the target
375 // is the same as the sign of exprs[0].
376 LinearArgumentProto int_mod = 8;
378 // The int_prod constraint forces the target to equal the product of all
379 // variables. By convention, because we can just remove term equal to one,
380 // the empty product forces the target to be one.
382 // Note that the solver checks for potential integer overflow. So the
383 // product of the maximum absolute value of all the terms (using the initial
384 // domain) should fit on an int64. Otherwise the model will be declared
386 LinearArgumentProto int_prod = 11;
388 // The lin_max constraint forces the target to equal the maximum of all
389 // linear expressions.
390 // Note that this can model a minimum simply by negating all expressions.
391 LinearArgumentProto lin_max = 27;
393 // The linear constraint enforces a linear inequality among the variables,
394 // such as 0 <= x + 2y <= 10.
395 LinearConstraintProto linear = 12;
397 // The all_diff constraint forces all variables to take different values.
398 AllDifferentConstraintProto all_diff = 13;
400 // The element constraint forces the variable with the given index
401 // to be equal to the target.
402 ElementConstraintProto element = 14;
404 // The circuit constraint takes a graph and forces the arcs present
405 // (with arc presence indicated by a literal) to form a unique cycle.
406 CircuitConstraintProto circuit = 15;
408 // The routes constraint implements the vehicle routing problem.
409 RoutesConstraintProto routes = 23;
411 // The table constraint enforces what values a tuple of variables may
413 TableConstraintProto table = 16;
415 // The automaton constraint forces a sequence of variables to be accepted
417 AutomatonConstraintProto automaton = 17;
419 // The inverse constraint forces two arrays to be inverses of each other:
420 // the values of one are the indices of the other, and vice versa.
421 InverseConstraintProto inverse = 18;
423 // The reservoir constraint forces the sum of a set of active demands
424 // to always be between a specified minimum and maximum value during
426 ReservoirConstraintProto reservoir = 24;
428 // Constraints on intervals.
430 // The first constraint defines what an "interval" is and the other
431 // constraints use references to it. All the intervals that have an
432 // enforcement_literal set to false are ignored by these constraints.
434 // TODO(user): Explain what happen for intervals of size zero. Some
435 // constraints ignore them; others do take them into account.
437 // The interval constraint takes a start, end, and size, and forces
438 // start + size == end.
439 IntervalConstraintProto interval = 19;
441 // The no_overlap constraint prevents a set of intervals from
442 // overlapping; in scheduling, this is called a disjunctive
444 NoOverlapConstraintProto no_overlap = 20;
446 // The no_overlap_2d constraint prevents a set of boxes from overlapping.
447 NoOverlap2DConstraintProto no_overlap_2d = 21;
449 // The cumulative constraint ensures that for any integer point, the sum
450 // of the demands of the intervals containing that point does not exceed
452 CumulativeConstraintProto cumulative = 22;
454 // This constraint is not meant to be used and will be rejected by the
455 // solver. It is meant to mark variable when testing the presolve code.
456 ListOfVariablesProto dummy_constraint = 30;
460// Optimization objective.
461message CpObjectiveProto {
462 // The linear terms of the objective to minimize.
463 // For a maximization problem, one can negate all coefficients in the
464 // objective and set scaling_factor to -1.
465 repeated int32 vars = 1;
466 repeated int64 coeffs = 4;
468 // The displayed objective is always:
469 // scaling_factor * (sum(coefficients[i] * objective_vars[i]) + offset).
470 // This is needed to have a consistent objective after presolve or when
471 // scaling a double problem to express it with integers.
473 // Note that if scaling_factor is zero, then it is assumed to be 1, so that by
474 // default these fields have no effect.
476 double scaling_factor = 3;
478 // If non-empty, only look for an objective value in the given domain.
479 // Note that this does not depend on the offset or scaling factor, it is a
480 // domain on the sum of the objective terms only.
481 repeated int64 domain = 5;
483 // Internal field. Do not set. When we scale a FloatObjectiveProto to a
484 // integer version, we set this to true if the scaling was exact (i.e. all
485 // original coeff were integer for instance).
487 // TODO(user): Put the error bounds we computed instead?
488 bool scaling_was_exact = 6;
490 // Internal fields to recover a bound on the original integer objective from
491 // the presolved one. Basically, initially the integer objective fit on an
492 // int64 and is in [Initial_lb, Initial_ub]. During presolve, we might change
493 // the linear expression to have a new domain [Presolved_lb, Presolved_ub]
494 // that will also always fit on an int64.
496 // The two domain will always be linked with an affine transformation between
497 // the two of the form:
498 // old = (new + before_offset) * integer_scaling_factor + after_offset.
499 // Note that we use both offsets to always be able to do the computation while
500 // staying in the int64 domain. In particular, the after_offset will always
501 // be in (-integer_scaling_factor, integer_scaling_factor).
502 int64 integer_before_offset = 7;
503 int64 integer_after_offset = 9;
504 int64 integer_scaling_factor = 8;
507// A linear floating point objective: sum coeffs[i] * vars[i] + offset.
508// Note that the variable can only still take integer value.
509message FloatObjectiveProto {
510 repeated int32 vars = 1;
511 repeated double coeffs = 2;
514 // The optimization direction. The default is to minimize
518// Define the strategy to follow when the solver needs to take a new decision.
519// Note that this strategy is only defined on a subset of variables.
520message DecisionStrategyProto {
521 // The variables to be considered for the next decision. The order matter and
522 // is always used as a tie-breaker after the variable selection strategy
523 // criteria defined below.
524 repeated int32 variables = 1;
526 // If this is set, then the variables field must be empty.
527 // We currently only support affine expression.
529 // Note that this is needed so that if a variable has an affine
530 // representative, we can properly transform a DecisionStrategyProto through
532 repeated LinearExpressionProto exprs = 5;
534 // The order in which the variables (resp. affine expression) above should be
535 // considered. Note that only variables that are not already fixed are
538 // TODO(user): extend as needed.
539 enum VariableSelectionStrategy {
541 CHOOSE_LOWEST_MIN = 1;
542 CHOOSE_HIGHEST_MAX = 2;
543 CHOOSE_MIN_DOMAIN_SIZE = 3;
544 CHOOSE_MAX_DOMAIN_SIZE = 4;
546 VariableSelectionStrategy variable_selection_strategy = 2;
548 // Once a variable (resp. affine expression) has been chosen, this enum
549 // describe what decision is taken on its domain.
551 // TODO(user): extend as needed.
552 enum DomainReductionStrategy {
553 SELECT_MIN_VALUE = 0;
554 SELECT_MAX_VALUE = 1;
555 SELECT_LOWER_HALF = 2;
556 SELECT_UPPER_HALF = 3;
557 SELECT_MEDIAN_VALUE = 4;
558 SELECT_RANDOM_HALF = 5;
560 DomainReductionStrategy domain_reduction_strategy = 3;
563// This message encodes a partial (or full) assignment of the variables of a
564// CpModelProto. The variable indices should be unique and valid variable
566message PartialVariableAssignment {
567 repeated int32 vars = 1;
568 repeated int64 values = 2;
571// A permutation of integers encoded as a list of cycles, hence the "sparse"
572// format. The image of an element cycle[i] is cycle[(i + 1) % cycle_length].
573message SparsePermutationProto {
574 // Each cycle is listed one after the other in the support field.
575 // The size of each cycle is given (in order) in the cycle_sizes field.
576 repeated int32 support = 1;
577 repeated int32 cycle_sizes = 2;
580// A dense matrix of numbers encoded in a flat way, row by row.
581// That is matrix[i][j] = entries[i * num_cols + j];
582message DenseMatrixProto {
585 repeated int32 entries = 3;
588// EXPERIMENTAL. For now, this is meant to be used by the solver and not filled
591// Hold symmetry information about the set of feasible solutions. If we permute
592// the variable values of any feasible solution using one of the permutation
593// described here, we should always get another feasible solution.
595// We usually also enforce that the objective of the new solution is the same.
597// The group of permutations encoded here is usually computed from the encoding
598// of the model, so it is not meant to be a complete representation of the
599// feasible solution symmetries, just a valid subgroup.
600message SymmetryProto {
601 // A list of variable indices permutations that leave the feasible space of
602 // solution invariant. Usually, we only encode a set of generators of the
604 repeated SparsePermutationProto permutations = 1;
606 // An orbitope is a special symmetry structure of the solution space. If the
607 // variable indices are arranged in a matrix (with no duplicates), then any
608 // permutation of the columns will be a valid permutation of the feasible
611 // This arise quite often. The typical example is a graph coloring problem
612 // where for each node i, you have j booleans to indicate its color. If the
613 // variables color_of_i_is_j are arranged in a matrix[i][j], then any columns
614 // permutations leave the problem invariant.
615 repeated DenseMatrixProto orbitopes = 2;
618// A constraint programming problem.
619message CpModelProto {
620 // For debug/logging only. Can be empty.
623 // The associated Protos should be referred by their index in these fields.
624 repeated IntegerVariableProto variables = 2;
625 repeated ConstraintProto constraints = 3;
627 // The objective to minimize. Can be empty for pure decision problems.
628 CpObjectiveProto objective = 4;
631 // It is invalid to have both an objective and a floating point objective.
633 // The objective of the model, in floating point format. The solver will
634 // automatically scale this to integer during expansion and thus convert it to
635 // a normal CpObjectiveProto. See the mip* parameters to control how this is
636 // scaled. In most situation the precision will be good enough, but you can
637 // see the logs to see what are the precision guaranteed when this is
638 // converted to a fixed point representation.
640 // Note that even if the precision is bad, the returned objective_value and
641 // best_objective_bound will be computed correctly. So at the end of the solve
642 // you can check the gap if you only want precise optimal.
643 FloatObjectiveProto floating_point_objective = 9;
645 // Defines the strategy that the solver should follow when the
646 // search_branching parameter is set to FIXED_SEARCH. Note that this strategy
647 // is also used as a heuristic when we are not in fixed search.
649 // Advanced Usage: if not all variables appears and the parameter
650 // "instantiate_all_variables" is set to false, then the solver will not try
651 // to instantiate the variables that do not appear. Thus, at the end of the
652 // search, not all variables may be fixed. Currently, we will set them to
653 // their lower bound in the solution.
654 repeated DecisionStrategyProto search_strategy = 5;
658 // If a feasible or almost-feasible solution to the problem is already known,
659 // it may be helpful to pass it to the solver so that it can be used. The
660 // solver will try to use this information to create its initial feasible
663 // Note that it may not always be faster to give a hint like this to the
664 // solver. There is also no guarantee that the solver will use this hint or
665 // try to return a solution "close" to this assignment in case of multiple
666 // optimal solutions.
667 PartialVariableAssignment solution_hint = 6;
669 // A list of literals. The model will be solved assuming all these literals
670 // are true. Compared to just fixing the domain of these literals, using this
671 // mechanism is slower but allows in case the model is INFEASIBLE to get a
672 // potentially small subset of them that can be used to explain the
675 // Think (IIS), except when you are only concerned by the provided
676 // assumptions. This is powerful as it allows to group a set of logically
677 // related constraint under only one enforcement literal which can potentially
678 // give you a good and interpretable explanation for infeasiblity.
680 // Such infeasibility explanation will be available in the
681 // sufficient_assumptions_for_infeasibility response field.
682 repeated int32 assumptions = 7;
684 // For now, this is not meant to be filled by a client writing a model, but
685 // by our preprocessing step.
687 // Information about the symmetries of the feasible solution space.
688 // These usually leaves the objective invariant.
689 SymmetryProto symmetry = 8;
692// The status returned by a solver trying to solve a CpModelProto.
694 // The status of the model is still unknown. A search limit has been reached
695 // before any of the statuses below could be determined.
698 // The given CpModelProto didn't pass the validation step. You can get a
699 // detailed error by calling ValidateCpModel(model_proto).
702 // A feasible solution has been found. But the search was stopped before we
703 // could prove optimality or before we enumerated all solutions of a
704 // feasibility problem (if asked).
707 // The problem has been proven infeasible.
710 // An optimal feasible solution has been found.
712 // More generally, this status represent a success. So we also return OPTIMAL
713 // if we find a solution for a pure feasibility problem or if a gap limit has
714 // been specified and we return a solution within this limit. In the case
715 // where we need to return all the feasible solution, this status will only be
716 // returned if we enumerated all of them; If we stopped before, we will return
721// Just a message used to store dense solution.
722// This is used by the additional_solutions field.
723message CpSolverSolution {
724 repeated int64 values = 1;
727// The response returned by a solver trying to solve a CpModelProto.
730message CpSolverResponse {
731 // The status of the solve.
732 CpSolverStatus status = 1;
734 // A feasible solution to the given problem. Depending on the returned status
735 // it may be optimal or just feasible. This is in one-to-one correspondence
736 // with a CpModelProto::variables repeated field and list the values of all
738 repeated int64 solution = 2;
740 // Only make sense for an optimization problem. The objective value of the
741 // returned solution if it is non-empty. If there is no solution, then for a
742 // minimization problem, this will be an upper-bound of the objective of any
743 // feasible solution, and a lower-bound for a maximization problem.
744 double objective_value = 3;
746 // Only make sense for an optimization problem. A proven lower-bound on the
747 // objective for a minimization problem, or a proven upper-bound for a
748 // maximization problem.
749 double best_objective_bound = 4;
751 // If the parameter fill_additional_solutions_in_response is set, then we
752 // copy all the solutions from our internal solution pool here.
754 // Note that the one returned in the solution field will likely appear here
755 // too. Do not rely on the solutions order as it depends on our internal
756 // representation (after postsolve).
757 repeated CpSolverSolution additional_solutions = 27;
761 // If the option fill_tightened_domains_in_response is set, then this field
762 // will be a copy of the CpModelProto.variables where each domain has been
763 // reduced using the information the solver was able to derive. Note that this
764 // is only filled with the info derived during a normal search and we do not
765 // have any dedicated algorithm to improve it.
767 // Warning: if you didn't set keep_all_feasible_solutions_in_presolve, then
768 // these domains might exclude valid feasible solution. Otherwise for a
769 // feasibility problem, all feasible solution should be there.
771 // Warning: For an optimization problem, these will correspond to valid bounds
772 // for the problem of finding an improving solution to the best one found so
773 // far. It might be better to solve a feasibility version if one just want to
774 // explore the feasible region.
775 repeated IntegerVariableProto tightened_variables = 21;
777 // A subset of the model "assumptions" field. This will only be filled if the
778 // status is INFEASIBLE. This subset of assumption will be enough to still get
779 // an infeasible problem.
781 // This is related to what is called the irreducible inconsistent subsystem or
782 // IIS. Except one is only concerned by the provided assumptions. There is
783 // also no guarantee that we return an irreducible (aka minimal subset).
784 // However, this is based on SAT explanation and there is a good chance it is
787 // If you really want a minimal subset, a possible way to get one is by
788 // changing your model to minimize the number of assumptions at false, but
789 // this is likely an harder problem to solve.
791 // Important: Currently, this is minimized only in single-thread and if the
792 // problem is not an optimization problem, otherwise, it will always include
793 // all the assumptions.
795 // TODO(user): Allows for returning multiple core at once.
796 repeated int32 sufficient_assumptions_for_infeasibility = 23;
798 // Contains the integer objective optimized internally. This is only filled if
799 // the problem had a floating point objective, and on the final response, not
800 // the ones given to callbacks.
801 CpObjectiveProto integer_objective = 28;
805 // A lower bound on the integer expression of the objective. This is either a
806 // bound on the expression in the returned integer_objective or on the integer
807 // expression of the original objective if the problem already has an integer
810 // TODO(user): This should be renamed integer_objective_lower_bound.
811 int64 inner_objective_lower_bound = 29;
813 // Some statistics about the solve.
815 // Important: in multithread, this correspond the statistics of the first
816 // subsolver. Which is usually the one with the user defined parameters. Or
817 // the default-search if none are specified.
818 int64 num_integers = 30;
819 int64 num_booleans = 10;
820 int64 num_fixed_booleans = 31;
821 int64 num_conflicts = 11;
822 int64 num_branches = 12;
823 int64 num_binary_propagations = 13;
824 int64 num_integer_propagations = 14;
825 int64 num_restarts = 24;
826 int64 num_lp_iterations = 25;
828 // The time counted from the beginning of the Solve() call.
829 double wall_time = 15;
830 double user_time = 16;
831 double deterministic_time = 17;
833 // The integral of log(1 + absolute_objective_gap) over time.
834 double gap_integral = 22;
836 // Additional information about how the solution was found. It also stores
837 // model or parameters errors that caused the model to be invalid.
838 string solution_info = 20;
840 // The solve log will be filled if the parameter log_to_response is set to
842 string solve_log = 26;