Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
gscip_solver_constraint_handler.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_MATH_OPT_SOLVERS_GSCIP_GSCIP_SOLVER_CONSTRAINT_HANDLER_H_
15#define OR_TOOLS_MATH_OPT_SOLVERS_GSCIP_GSCIP_SOLVER_CONSTRAINT_HANDLER_H_
16
17#include <cstdint>
18#include <utility>
19#include <vector>
20
21#include "absl/status/status.h"
22#include "absl/status/statusor.h"
23#include "absl/time/time.h"
25#include "ortools/gscip/gscip.h"
28#include "ortools/math_opt/callback.pb.h"
30#include "scip/type_var.h"
31
33
37 const SparseVectorFilterProto* variable_node_filter = nullptr;
38 const SparseVectorFilterProto* variable_solution_filter = nullptr;
39 absl::Time solve_start_time = absl::UnixEpoch();
40 bool run_at_nodes = false;
41 bool run_at_solutions = false;
42 bool adds_cuts = false;
44 GScip::Interrupter* interrupter = nullptr;
45
46 void SetWhenRunAndAdds(const CallbackRegistrationProto& registration);
47
48 // Ensures that when GScipSolverConstraintData::user_callback != nullptr, we
49 // also have that variables, variable_node_filter, variable_solution_filter,
50 // and interrupter are not nullptr as well. In a callback, when user_callback
51 // is nullptr, do not access these fields!
52 absl::Status Validate() const;
53};
54
56 : public GScipConstraintHandler<GScipSolverConstraintData> {
57 public:
59
60 private:
61 absl::StatusOr<GScipCallbackResult> EnforceLp(
63 const GScipSolverConstraintData& constraint_data,
64 bool solution_infeasible) override;
65
66 absl::StatusOr<bool> CheckIsFeasible(
68 const GScipSolverConstraintData& constraint_data, bool check_integrality,
69 bool check_lp_rows, bool print_reason, bool check_completely) override;
70
71 absl::StatusOr<GScipCallbackResult> SeparateLp(
73 const GScipSolverConstraintData& constraint_data) override;
74
75 absl::StatusOr<GScipCallbackResult> SeparateSolution(
77 const GScipSolverConstraintData& constraint_data) override;
78
79 std::vector<std::pair<SCIP_VAR*, RoundingLockDirection>> RoundingLock(
80 GScip* gscip, const GScipSolverConstraintData& constraint_data,
81 bool lock_type_is_model) override;
82
83 // Requires that constraint_data.Validate() has already been called.
84 absl::StatusOr<CallbackDataProto> MakeCbData(
86 const GScipSolverConstraintData& constraint_data,
87 CallbackEventProto event);
88
89 // If ok, returned value will be one of {cutoff, lazy, cut, feasible}.
90 //
91 // Requires that constraint_data.Validate() has already been called.
92 absl::StatusOr<GScipCallbackResult> ApplyCallback(
93 const CallbackResultProto& result, GScipConstraintHandlerContext& context,
94 const GScipSolverConstraintData& constraint_data,
96};
97
98} // namespace operations_research::math_opt
99
100#endif // OR_TOOLS_MATH_OPT_SOLVERS_GSCIP_GSCIP_SOLVER_CONSTRAINT_HANDLER_H_
std::function< absl::StatusOr< CallbackResultProto >( const CallbackDataProto &)> Callback
GurobiMPCallbackContext * context
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
void SetWhenRunAndAdds(const CallbackRegistrationProto &registration)
const gtl::linked_hash_map< int64_t, SCIP_VAR * > * variables