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 affine 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 target = vars[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 // All expressions below must be affine function with at most one variable.
112 LinearExpressionProto linear_index = 4;
113 LinearExpressionProto linear_target = 5;
114 repeated LinearExpressionProto exprs = 6;
117// This is not really a constraint. It is there so it can be referred by other
118// constraints using this "interval" concept.
120// IMPORTANT: For now, this constraint do not enforce any relations on the
121// components, and it is up to the client to add in the model:
122// - enforcement => start + size == end.
123// - enforcement => size >= 0 // Only needed if size is not already >= 0.
125// IMPORTANT: For now, we just support affine relation. We could easily
126// create an intermediate variable to support full linear expression, but this
127// isn't done currently.
128message IntervalConstraintProto {
129 LinearExpressionProto start = 4;
130 LinearExpressionProto end = 5;
131 LinearExpressionProto size = 6;
134// All the intervals (index of IntervalConstraintProto) must be disjoint. More
135// formally, there must exist a sequence so that for each consecutive intervals,
136// we have end_i <= start_{i+1}. In particular, intervals of size zero do matter
137// for this constraint. This is also known as a disjunctive constraint in
139message NoOverlapConstraintProto {
140 repeated int32 intervals = 1;
143// The boxes defined by [start_x, end_x) * [start_y, end_y) cannot overlap.
144// Furthermore, one box is optional if at least one of the x or y interval is
147// Note that the case of boxes of size zero is special. The following cases
148// violate the constraint:
149// - a point box inside a box with a non zero area
150// - a line box overlapping a box with a non zero area
151// - one vertical line box crossing an horizontal line box.
152message NoOverlap2DConstraintProto {
153 repeated int32 x_intervals = 1;
154 repeated int32 y_intervals = 2; // Same size as x_intervals.
157// The sum of the demands of the intervals at each interval point cannot exceed
158// a capacity. Note that intervals are interpreted as [start, end) and as
159// such intervals like [2,3) and [3,4) do not overlap for the point of view of
160// this constraint. Moreover, intervals of size zero are ignored.
162// All demands must not contain any negative value in their domains. This is
163// checked at validation. Even if there are no intervals, this constraint
164// implicit enforces capacity >= 0. In other words, a negative capacity is
165// considered valid but always infeasible.
166message CumulativeConstraintProto {
167 LinearExpressionProto capacity = 1;
168 repeated int32 intervals = 2;
169 repeated LinearExpressionProto demands = 3; // Same size as intervals.
172// Maintain a reservoir level within bounds. The water level starts at 0, and at
173// any time, it must be within [min_level, max_level].
175// If the variable active_literals[i] is true, and if the expression
176// time_exprs[i] is assigned a value t, then the current level changes by
177// level_changes[i] at the time t. Therefore, at any time t:
179// sum(level_changes[i] * active_literals[i] if time_exprs[i] <= t)
180// in [min_level, max_level]
182// Note that min level must be <= 0, and the max level must be >= 0. Please use
183// fixed level_changes to simulate initial state.
185// The array of boolean variables 'actives', if defined, indicates which actions
186// are actually performed. If this array is not defined, then it is assumed that
187// all actions will be performed.
188message ReservoirConstraintProto {
191 repeated LinearExpressionProto time_exprs = 3; // affine expressions.
192 // Currently, we only support constant level changes.
193 repeated LinearExpressionProto level_changes = 6; // affine expressions.
194 repeated int32 active_literals = 5;
198// The circuit constraint is defined on a graph where the arc presence are
199// controlled by literals. Each arc is given by an index in the
200// tails/heads/literals lists that must have the same size.
202// For now, we ignore node indices with no incident arc. All the other nodes
203// must have exactly one incoming and one outgoing selected arc (i.e. literal at
204// true). All the selected arcs that are not self-loops must form a single
205// circuit. Note that multi-arcs are allowed, but only one of them will be true
206// at the same time. Multi-self loop are disallowed though.
207message CircuitConstraintProto {
208 repeated int32 tails = 3;
209 repeated int32 heads = 4;
210 repeated int32 literals = 5;
213// The "VRP" (Vehicle Routing Problem) constraint.
215// The direct graph where arc #i (from tails[i] to head[i]) is present iff
216// literals[i] is true must satisfy this set of properties:
217// - #incoming arcs == 1 except for node 0.
218// - #outgoing arcs == 1 except for node 0.
219// - for node zero, #incoming arcs == #outgoing arcs.
220// - There are no duplicate arcs.
221// - Self-arcs are allowed except for node 0.
222// - There is no cycle in this graph, except through node 0.
224// Note: Currently this constraint expect all the nodes in [0, num_nodes) to
225// have at least one incident arc. The model will be considered invalid if it
226// is not the case. You can add self-arc fixed to one to ignore some nodes if
229// TODO(user): It is probably possible to generalize this constraint to a
230// no-cycle in a general graph, or a no-cycle with sum incoming <= 1 and sum
231// outgoing <= 1 (more efficient implementation). On the other hand, having this
232// specific constraint allow us to add specific "cuts" to a VRP problem.
233message RoutesConstraintProto {
234 repeated int32 tails = 1;
235 repeated int32 heads = 2;
236 repeated int32 literals = 3;
238 // EXPERIMENTAL. The demands for each node, and the maximum capacity for each
239 // route. Note that this is currently only used for the LP relaxation and one
240 // need to add the corresponding constraint to enforce this outside of the LP.
242 // TODO(user): Ideally, we should be able to extract any dimension like these
243 // (i.e. capacity, route_length, etc..) automatically from the encoding. The
244 // classical way to encode that is to have "current_capacity" variables along
245 // the route and linear equations of the form:
246 // arc_literal => (current_capacity_tail + demand <= current_capacity_head)
247 repeated int32 demands = 4;
251// The values of the n-tuple formed by the given expression can only be one of
252// the listed n-tuples in values. The n-tuples are encoded in a flattened way:
253// [tuple0_v0, tuple0_v1, ..., tuple0_v{n-1}, tuple1_v0, ...].
254// Expressions must be affine (a * var + b).
256// - If all `vars`, `values` and `exprs` are empty, the constraint is trivially
257// true, irrespective of the value of `negated`.
258// - If `values` is empty but either vars or exprs is not, the constraint is
259// trivially false if `negated` is false, and trivially true if `negated` is
261// - If `vars` and `exprs` are empty but `values` is not, the model is invalid.
262message TableConstraintProto {
263 repeated int32 vars = 1; // Legacy field.
264 repeated int64 values = 2;
265 repeated LinearExpressionProto exprs = 4;
267 // If true, the meaning is "negated", that is we forbid any of the given
268 // tuple from a feasible assignment.
272// The two arrays of variable each represent a function, the second is the
273// inverse of the first: f_direct[i] == j <=> f_inverse[j] == i.
274message InverseConstraintProto {
275 repeated int32 f_direct = 1;
276 repeated int32 f_inverse = 2;
279// This constraint forces a sequence of expressions to be accepted by an
281message AutomatonConstraintProto {
282 // A state is identified by a non-negative number. It is preferable to keep
283 // all the states dense in says [0, num_states). The automaton starts at
284 // starting_state and must finish in any of the final states.
285 int64 starting_state = 2;
286 repeated int64 final_states = 3;
288 // List of transitions (all 3 vectors have the same size). Both tail and head
289 // are states, label is any variable value. No two outgoing transitions from
290 // the same state can have the same label.
291 repeated int64 transition_tail = 4;
292 repeated int64 transition_head = 5;
293 repeated int64 transition_label = 6;
296 repeated int32 vars = 7;
297 // The sequence of affine expressions (a * var + b). The automaton is ran for
298 // exprs_size() "steps" and the value of exprs[i] corresponds to the
299 // transition label at step i.
300 repeated LinearExpressionProto exprs = 8;
303// A list of variables, without any semantics.
304message ListOfVariablesProto {
305 repeated int32 vars = 1;
309message ConstraintProto {
310 // For debug/logging only. Can be empty.
313 // The constraint will be enforced iff all literals listed here are true. If
314 // this is empty, then the constraint will always be enforced. An enforced
315 // constraint must be satisfied, and an un-enforced one will simply be
318 // This is also called half-reification. To have an equivalence between a
319 // literal and a constraint (full reification), one must add both a constraint
320 // (controlled by a literal l) and its negation (controlled by the negation of
323 // Important: as of September 2018, only a few constraint support enforcement:
324 // - bool_or, bool_and, linear: fully supported.
325 // - interval: only support a single enforcement literal.
326 // - other: no support (but can be added on a per-demand basis).
327 repeated int32 enforcement_literal = 2;
329 // The actual constraint with its arguments.
331 // The bool_or constraint forces at least one literal to be true.
332 BoolArgumentProto bool_or = 3;
334 // The bool_and constraint forces all of the literals to be true.
336 // This is a "redundant" constraint in the sense that this can easily be
337 // encoded with many bool_or or at_most_one. It is just more space efficient
338 // and handled slightly differently internally.
339 BoolArgumentProto bool_and = 4;
341 // The at_most_one constraint enforces that no more than one literal is
342 // true at the same time.
344 // Note that an at most one constraint of length n could be encoded with n
345 // bool_and constraint with n-1 term on the right hand side. So in a sense,
346 // this constraint contribute directly to the "implication-graph" or the
347 // 2-SAT part of the model.
349 // This constraint does not support enforcement_literal. Just use a linear
350 // constraint if you need to enforce it. You also do not need to use it
351 // directly, we will extract it from the model in most situations.
352 BoolArgumentProto at_most_one = 26;
354 // The exactly_one constraint force exactly one literal to true and no more.
356 // Anytime a bool_or (it could have been called at_least_one) is included
357 // into an at_most_one, then the bool_or is actually an exactly one
358 // constraint, and the extra literal in the at_most_one can be set to false.
359 // So in this sense, this constraint is not really needed. it is just here
360 // for a better description of the problem structure and to facilitate some
363 // This constraint does not support enforcement_literal. Just use a linear
364 // constraint if you need to enforce it. You also do not need to use it
365 // directly, we will extract it from the model in most situations.
366 BoolArgumentProto exactly_one = 29;
368 // The bool_xor constraint forces an odd number of the literals to be true.
369 BoolArgumentProto bool_xor = 5;
371 // The int_div constraint forces the target to equal exprs[0] / exprs[1].
372 // The division is "rounded" towards zero, so we can have for instance
373 // (2 = 12 / 5) or (-3 = -10 / 3). If you only want exact integer division,
374 // then you should use instead of t = a / b, the int_prod constraint
377 // If 0 belongs to the domain of exprs[1], then the model is deemed invalid.
378 LinearArgumentProto int_div = 7;
380 // The int_mod constraint forces the target to equal exprs[0] % exprs[1].
381 // The domain of exprs[1] must be strictly positive. The sign of the target
382 // is the same as the sign of exprs[0].
383 LinearArgumentProto int_mod = 8;
385 // The int_prod constraint forces the target to equal the product of all
386 // variables. By convention, because we can just remove term equal to one,
387 // the empty product forces the target to be one.
389 // Note that the solver checks for potential integer overflow. So the
390 // product of the maximum absolute value of all the terms (using the initial
391 // domain) should fit on an int64. Otherwise the model will be declared
393 LinearArgumentProto int_prod = 11;
395 // The lin_max constraint forces the target to equal the maximum of all
396 // linear expressions.
397 // Note that this can model a minimum simply by negating all expressions.
398 LinearArgumentProto lin_max = 27;
400 // The linear constraint enforces a linear inequality among the variables,
401 // such as 0 <= x + 2y <= 10.
402 LinearConstraintProto linear = 12;
404 // The all_diff constraint forces all variables to take different values.
405 AllDifferentConstraintProto all_diff = 13;
407 // The element constraint forces the variable with the given index
408 // to be equal to the target.
409 ElementConstraintProto element = 14;
411 // The circuit constraint takes a graph and forces the arcs present
412 // (with arc presence indicated by a literal) to form a unique cycle.
413 CircuitConstraintProto circuit = 15;
415 // The routes constraint implements the vehicle routing problem.
416 RoutesConstraintProto routes = 23;
418 // The table constraint enforces what values a tuple of variables may
420 TableConstraintProto table = 16;
422 // The automaton constraint forces a sequence of variables to be accepted
424 AutomatonConstraintProto automaton = 17;
426 // The inverse constraint forces two arrays to be inverses of each other:
427 // the values of one are the indices of the other, and vice versa.
428 InverseConstraintProto inverse = 18;
430 // The reservoir constraint forces the sum of a set of active demands
431 // to always be between a specified minimum and maximum value during
433 ReservoirConstraintProto reservoir = 24;
435 // Constraints on intervals.
437 // The first constraint defines what an "interval" is and the other
438 // constraints use references to it. All the intervals that have an
439 // enforcement_literal set to false are ignored by these constraints.
441 // TODO(user): Explain what happen for intervals of size zero. Some
442 // constraints ignore them; others do take them into account.
444 // The interval constraint takes a start, end, and size, and forces
445 // start + size == end.
446 IntervalConstraintProto interval = 19;
448 // The no_overlap constraint prevents a set of intervals from
449 // overlapping; in scheduling, this is called a disjunctive
451 NoOverlapConstraintProto no_overlap = 20;
453 // The no_overlap_2d constraint prevents a set of boxes from overlapping.
454 NoOverlap2DConstraintProto no_overlap_2d = 21;
456 // The cumulative constraint ensures that for any integer point, the sum
457 // of the demands of the intervals containing that point does not exceed
459 CumulativeConstraintProto cumulative = 22;
461 // This constraint is not meant to be used and will be rejected by the
462 // solver. It is meant to mark variable when testing the presolve code.
463 ListOfVariablesProto dummy_constraint = 30;
467// Optimization objective.
468message CpObjectiveProto {
469 // The linear terms of the objective to minimize.
470 // For a maximization problem, one can negate all coefficients in the
471 // objective and set scaling_factor to -1.
472 repeated int32 vars = 1;
473 repeated int64 coeffs = 4;
475 // The displayed objective is always:
476 // scaling_factor * (sum(coefficients[i] * objective_vars[i]) + offset).
477 // This is needed to have a consistent objective after presolve or when
478 // scaling a double problem to express it with integers.
480 // Note that if scaling_factor is zero, then it is assumed to be 1, so that by
481 // default these fields have no effect.
483 double scaling_factor = 3;
485 // If non-empty, only look for an objective value in the given domain.
486 // Note that this does not depend on the offset or scaling factor, it is a
487 // domain on the sum of the objective terms only.
488 repeated int64 domain = 5;
490 // Internal field. Do not set. When we scale a FloatObjectiveProto to a
491 // integer version, we set this to true if the scaling was exact (i.e. all
492 // original coeff were integer for instance).
494 // TODO(user): Put the error bounds we computed instead?
495 bool scaling_was_exact = 6;
497 // Internal fields to recover a bound on the original integer objective from
498 // the presolved one. Basically, initially the integer objective fit on an
499 // int64 and is in [Initial_lb, Initial_ub]. During presolve, we might change
500 // the linear expression to have a new domain [Presolved_lb, Presolved_ub]
501 // that will also always fit on an int64.
503 // The two domain will always be linked with an affine transformation between
504 // the two of the form:
505 // old = (new + before_offset) * integer_scaling_factor + after_offset.
506 // Note that we use both offsets to always be able to do the computation while
507 // staying in the int64 domain. In particular, the after_offset will always
508 // be in (-integer_scaling_factor, integer_scaling_factor).
509 int64 integer_before_offset = 7;
510 int64 integer_after_offset = 9;
511 int64 integer_scaling_factor = 8;
514// A linear floating point objective: sum coeffs[i] * vars[i] + offset.
515// Note that the variable can only still take integer value.
516message FloatObjectiveProto {
517 repeated int32 vars = 1;
518 repeated double coeffs = 2;
521 // The optimization direction. The default is to minimize
525// Define the strategy to follow when the solver needs to take a new decision.
526// Note that this strategy is only defined on a subset of variables.
527message DecisionStrategyProto {
528 // The variables to be considered for the next decision. The order matter and
529 // is always used as a tie-breaker after the variable selection strategy
530 // criteria defined below.
531 repeated int32 variables = 1;
533 // If this is set, then the variables field must be empty.
534 // We currently only support affine expression.
536 // Note that this is needed so that if a variable has an affine
537 // representative, we can properly transform a DecisionStrategyProto through
539 repeated LinearExpressionProto exprs = 5;
541 // The order in which the variables (resp. affine expression) above should be
542 // considered. Note that only variables that are not already fixed are
545 // TODO(user): extend as needed.
546 enum VariableSelectionStrategy {
548 CHOOSE_LOWEST_MIN = 1;
549 CHOOSE_HIGHEST_MAX = 2;
550 CHOOSE_MIN_DOMAIN_SIZE = 3;
551 CHOOSE_MAX_DOMAIN_SIZE = 4;
553 VariableSelectionStrategy variable_selection_strategy = 2;
555 // Once a variable (resp. affine expression) has been chosen, this enum
556 // describe what decision is taken on its domain.
558 // TODO(user): extend as needed.
559 enum DomainReductionStrategy {
560 SELECT_MIN_VALUE = 0;
561 SELECT_MAX_VALUE = 1;
562 SELECT_LOWER_HALF = 2;
563 SELECT_UPPER_HALF = 3;
564 SELECT_MEDIAN_VALUE = 4;
565 SELECT_RANDOM_HALF = 5;
567 DomainReductionStrategy domain_reduction_strategy = 3;
570// This message encodes a partial (or full) assignment of the variables of a
571// CpModelProto. The variable indices should be unique and valid variable
573message PartialVariableAssignment {
574 repeated int32 vars = 1;
575 repeated int64 values = 2;
578// A permutation of integers encoded as a list of cycles, hence the "sparse"
579// format. The image of an element cycle[i] is cycle[(i + 1) % cycle_length].
580message SparsePermutationProto {
581 // Each cycle is listed one after the other in the support field.
582 // The size of each cycle is given (in order) in the cycle_sizes field.
583 repeated int32 support = 1;
584 repeated int32 cycle_sizes = 2;
587// A dense matrix of numbers encoded in a flat way, row by row.
588// That is matrix[i][j] = entries[i * num_cols + j];
589message DenseMatrixProto {
592 repeated int32 entries = 3;
595// EXPERIMENTAL. For now, this is meant to be used by the solver and not filled
598// Hold symmetry information about the set of feasible solutions. If we permute
599// the variable values of any feasible solution using one of the permutation
600// described here, we should always get another feasible solution.
602// We usually also enforce that the objective of the new solution is the same.
604// The group of permutations encoded here is usually computed from the encoding
605// of the model, so it is not meant to be a complete representation of the
606// feasible solution symmetries, just a valid subgroup.
607message SymmetryProto {
608 // A list of variable indices permutations that leave the feasible space of
609 // solution invariant. Usually, we only encode a set of generators of the
611 repeated SparsePermutationProto permutations = 1;
613 // An orbitope is a special symmetry structure of the solution space. If the
614 // variable indices are arranged in a matrix (with no duplicates), then any
615 // permutation of the columns will be a valid permutation of the feasible
618 // This arise quite often. The typical example is a graph coloring problem
619 // where for each node i, you have j booleans to indicate its color. If the
620 // variables color_of_i_is_j are arranged in a matrix[i][j], then any columns
621 // permutations leave the problem invariant.
622 repeated DenseMatrixProto orbitopes = 2;
625// A constraint programming problem.
626message CpModelProto {
627 // For debug/logging only. Can be empty.
630 // The associated Protos should be referred by their index in these fields.
631 repeated IntegerVariableProto variables = 2;
632 repeated ConstraintProto constraints = 3;
634 // The objective to minimize. Can be empty for pure decision problems.
635 CpObjectiveProto objective = 4;
638 // It is invalid to have both an objective and a floating point objective.
640 // The objective of the model, in floating point format. The solver will
641 // automatically scale this to integer during expansion and thus convert it to
642 // a normal CpObjectiveProto. See the mip* parameters to control how this is
643 // scaled. In most situation the precision will be good enough, but you can
644 // see the logs to see what are the precision guaranteed when this is
645 // converted to a fixed point representation.
647 // Note that even if the precision is bad, the returned objective_value and
648 // best_objective_bound will be computed correctly. So at the end of the solve
649 // you can check the gap if you only want precise optimal.
650 FloatObjectiveProto floating_point_objective = 9;
652 // Defines the strategy that the solver should follow when the
653 // search_branching parameter is set to FIXED_SEARCH. Note that this strategy
654 // is also used as a heuristic when we are not in fixed search.
656 // Advanced Usage: if not all variables appears and the parameter
657 // "instantiate_all_variables" is set to false, then the solver will not try
658 // to instantiate the variables that do not appear. Thus, at the end of the
659 // search, not all variables may be fixed. Currently, we will set them to
660 // their lower bound in the solution.
661 repeated DecisionStrategyProto search_strategy = 5;
665 // If a feasible or almost-feasible solution to the problem is already known,
666 // it may be helpful to pass it to the solver so that it can be used. The
667 // solver will try to use this information to create its initial feasible
670 // Note that it may not always be faster to give a hint like this to the
671 // solver. There is also no guarantee that the solver will use this hint or
672 // try to return a solution "close" to this assignment in case of multiple
673 // optimal solutions.
674 PartialVariableAssignment solution_hint = 6;
676 // A list of literals. The model will be solved assuming all these literals
677 // are true. Compared to just fixing the domain of these literals, using this
678 // mechanism is slower but allows in case the model is INFEASIBLE to get a
679 // potentially small subset of them that can be used to explain the
682 // Think (IIS), except when you are only concerned by the provided
683 // assumptions. This is powerful as it allows to group a set of logically
684 // related constraint under only one enforcement literal which can potentially
685 // give you a good and interpretable explanation for infeasiblity.
687 // Such infeasibility explanation will be available in the
688 // sufficient_assumptions_for_infeasibility response field.
689 repeated int32 assumptions = 7;
691 // For now, this is not meant to be filled by a client writing a model, but
692 // by our preprocessing step.
694 // Information about the symmetries of the feasible solution space.
695 // These usually leaves the objective invariant.
696 SymmetryProto symmetry = 8;
699// The status returned by a solver trying to solve a CpModelProto.
701 // The status of the model is still unknown. A search limit has been reached
702 // before any of the statuses below could be determined.
705 // The given CpModelProto didn't pass the validation step. You can get a
706 // detailed error by calling ValidateCpModel(model_proto).
709 // A feasible solution has been found. But the search was stopped before we
710 // could prove optimality or before we enumerated all solutions of a
711 // feasibility problem (if asked).
714 // The problem has been proven infeasible.
717 // An optimal feasible solution has been found.
719 // More generally, this status represent a success. So we also return OPTIMAL
720 // if we find a solution for a pure feasibility problem or if a gap limit has
721 // been specified and we return a solution within this limit. In the case
722 // where we need to return all the feasible solution, this status will only be
723 // returned if we enumerated all of them; If we stopped before, we will return
728// Just a message used to store dense solution.
729// This is used by the additional_solutions field.
730message CpSolverSolution {
731 repeated int64 values = 1;
734// The response returned by a solver trying to solve a CpModelProto.
737message CpSolverResponse {
738 // The status of the solve.
739 CpSolverStatus status = 1;
741 // A feasible solution to the given problem. Depending on the returned status
742 // it may be optimal or just feasible. This is in one-to-one correspondence
743 // with a CpModelProto::variables repeated field and list the values of all
745 repeated int64 solution = 2;
747 // Only make sense for an optimization problem. The objective value of the
748 // returned solution if it is non-empty. If there is no solution, then for a
749 // minimization problem, this will be an upper-bound of the objective of any
750 // feasible solution, and a lower-bound for a maximization problem.
751 double objective_value = 3;
753 // Only make sense for an optimization problem. A proven lower-bound on the
754 // objective for a minimization problem, or a proven upper-bound for a
755 // maximization problem.
756 double best_objective_bound = 4;
758 // If the parameter fill_additional_solutions_in_response is set, then we
759 // copy all the solutions from our internal solution pool here.
761 // Note that the one returned in the solution field will likely appear here
762 // too. Do not rely on the solutions order as it depends on our internal
763 // representation (after postsolve).
764 repeated CpSolverSolution additional_solutions = 27;
768 // If the option fill_tightened_domains_in_response is set, then this field
769 // will be a copy of the CpModelProto.variables where each domain has been
770 // reduced using the information the solver was able to derive. Note that this
771 // is only filled with the info derived during a normal search and we do not
772 // have any dedicated algorithm to improve it.
774 // Warning: if you didn't set keep_all_feasible_solutions_in_presolve, then
775 // these domains might exclude valid feasible solution. Otherwise for a
776 // feasibility problem, all feasible solution should be there.
778 // Warning: For an optimization problem, these will correspond to valid bounds
779 // for the problem of finding an improving solution to the best one found so
780 // far. It might be better to solve a feasibility version if one just want to
781 // explore the feasible region.
782 repeated IntegerVariableProto tightened_variables = 21;
784 // A subset of the model "assumptions" field. This will only be filled if the
785 // status is INFEASIBLE. This subset of assumption will be enough to still get
786 // an infeasible problem.
788 // This is related to what is called the irreducible inconsistent subsystem or
789 // IIS. Except one is only concerned by the provided assumptions. There is
790 // also no guarantee that we return an irreducible (aka minimal subset).
791 // However, this is based on SAT explanation and there is a good chance it is
794 // If you really want a minimal subset, a possible way to get one is by
795 // changing your model to minimize the number of assumptions at false, but
796 // this is likely an harder problem to solve.
798 // Important: Currently, this is minimized only in single-thread and if the
799 // problem is not an optimization problem, otherwise, it will always include
800 // all the assumptions.
802 // TODO(user): Allows for returning multiple core at once.
803 repeated int32 sufficient_assumptions_for_infeasibility = 23;
805 // Contains the integer objective optimized internally. This is only filled if
806 // the problem had a floating point objective, and on the final response, not
807 // the ones given to callbacks.
808 CpObjectiveProto integer_objective = 28;
812 // A lower bound on the inner integer expression of the objective. This is
813 // either a bound on the expression in the returned integer_objective or on
814 // the integer expression of the original objective if the problem already has
815 // an integer objective.
816 int64 inner_objective_lower_bound = 29;
818 // Some statistics about the solve.
820 // Important: in multithread, this correspond the statistics of the first
821 // subsolver. Which is usually the one with the user defined parameters. Or
822 // the default-search if none are specified.
823 int64 num_integers = 30;
824 int64 num_booleans = 10;
825 int64 num_fixed_booleans = 31;
826 int64 num_conflicts = 11;
827 int64 num_branches = 12;
828 int64 num_binary_propagations = 13;
829 int64 num_integer_propagations = 14;
830 int64 num_restarts = 24;
831 int64 num_lp_iterations = 25;
833 // The time counted from the beginning of the Solve() call.
834 double wall_time = 15;
835 double user_time = 16;
836 double deterministic_time = 17;
838 // The integral of log(1 + absolute_objective_gap) over time.
839 double gap_integral = 22;
841 // Additional information about how the solution was found. It also stores
842 // model or parameters errors that caused the model to be invalid.
843 string solution_info = 20;
845 // The solve log will be filled if the parameter log_to_response is set to
847 string solve_log = 26;