Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
linear_model.h
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_SAT_LINEAR_MODEL_H_
15#define OR_TOOLS_SAT_LINEAR_MODEL_H_
16
17#include <vector>
18
19#include "ortools/sat/cp_model.pb.h"
20
21namespace operations_research {
22namespace sat {
23
24// This class is meant to be a view on the full CpModelProto, with hidden and
25// additional constraints.
26// Currently, this class is meant to be used by the feasibility jump subsolver.
27// It could also contains the linear relaxation at level 1 or 2 of the model and
28// could be computed once for all workers of a given linearization level.
30 public:
31 explicit LinearModel(const CpModelProto& model_proto);
32
33 const CpModelProto& model_proto() const { return model_proto_; }
34
35 // Mask on the constraints of the model passed to the ctor.
36 const std::vector<bool>& ignored_constraints() const {
37 return ignored_constraints_;
38 }
39
40 // Additional constraints created during the initialization.
41 const std::vector<ConstraintProto>& additional_constraints() const {
42 return additional_constraints_;
43 }
44
45 int num_ignored_constraints() const { return num_ignored_constraints_; }
46 int num_exactly_ones() const { return num_exactly_ones_; }
47 int num_full_encodings() const { return num_full_encodings_; }
48 int num_element_encodings() const { return num_element_encodings_; }
49
50 private:
51 // Initial model.
52 const CpModelProto& model_proto_;
53
54 // Model delta.
55 std::vector<bool> ignored_constraints_;
56 std::vector<ConstraintProto> additional_constraints_;
57
58 // Statistics.
59 int num_ignored_constraints_ = 0;
60 int num_exactly_ones_ = 0;
61 int num_full_encodings_ = 0;
62 int num_element_encodings_ = 0;
63};
64
65} // namespace sat
66} // namespace operations_research
67
68#endif // OR_TOOLS_SAT_LINEAR_MODEL_H_
const CpModelProto & model_proto() const
LinearModel(const CpModelProto &model_proto)
const std::vector< bool > & ignored_constraints() const
Mask on the constraints of the model passed to the ctor.
const std::vector< ConstraintProto > & additional_constraints() const
Additional constraints created during the initialization.
In SWIG mode, we don't want anything besides these top-level includes.