Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
integral_solver.h
Go to the documentation of this file.
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
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_BOP_INTEGRAL_SOLVER_H_
15#define OR_TOOLS_BOP_INTEGRAL_SOLVER_H_
16
17#include "absl/base/attributes.h"
23
24namespace operations_research {
25namespace bop {
26// This class implements an Integer Programming solver, i.e. the solver solves
27// problems with both integral and boolean variables, linear constraint and
28// linear objective function.
30 public:
32
33 // This type is neither copyable nor movable.
36
37 ~IntegralSolver() = default;
38
39 // Sets the solver parameters.
40 // See the proto for an extensive documentation.
42 parameters_ = parameters;
43 }
44 BopParameters parameters() const { return parameters_; }
45
46 // Solves the given linear program and returns the solve status.
47 ABSL_MUST_USE_RESULT BopSolveStatus
48 Solve(const glop::LinearProgram& linear_problem);
49 ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(
50 const glop::LinearProgram& linear_problem, TimeLimit* time_limit);
51
52 // Same as Solve() but starts from the given solution.
53 // TODO(user): Change the API to accept a partial solution instead since the
54 // underlying solver supports it.
55 ABSL_MUST_USE_RESULT BopSolveStatus
56 Solve(const glop::LinearProgram& linear_problem,
57 const glop::DenseRow& user_provided_initial_solution);
58 ABSL_MUST_USE_RESULT BopSolveStatus
59 SolveWithTimeLimit(const glop::LinearProgram& linear_problem,
60 const glop::DenseRow& user_provided_initial_solution,
62
63 // Returns the objective value of the solution with its offset.
64 glop::Fractional objective_value() const { return objective_value_; }
65
66 // Returns the best bound found so far.
67 glop::Fractional best_bound() const { return best_bound_; }
68
69 // Returns the solution values. Note that the values only make sense when a
70 // solution is found.
71 const glop::DenseRow& variable_values() const { return variable_values_; }
72
73 private:
74 BopParameters parameters_;
75 glop::DenseRow variable_values_;
76 glop::Fractional objective_value_;
77 glop::Fractional best_bound_;
78};
79} // namespace bop
80} // namespace operations_research
81#endif // OR_TOOLS_BOP_INTEGRAL_SOLVER_H_
const glop::DenseRow & variable_values() const
IntegralSolver(const IntegralSolver &)=delete
This type is neither copyable nor movable.
glop::Fractional best_bound() const
Returns the best bound found so far.
IntegralSolver & operator=(const IntegralSolver &)=delete
glop::Fractional objective_value() const
Returns the objective value of the solution with its offset.
void SetParameters(const BopParameters &parameters)
ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(const glop::LinearProgram &linear_problem, TimeLimit *time_limit)
ABSL_MUST_USE_RESULT BopSolveStatus Solve(const glop::LinearProgram &linear_problem)
Solves the given linear program and returns the solve status.
time_limit
Definition solve.cc:22
BopSolveStatus
Status of the solve of Bop.
Definition bop_types.h:34
StrictITIVector< ColIndex, Fractional > DenseRow
Row-vector types. Row-vector types are indexed by a column index.
Definition lp_types.h:351
In SWIG mode, we don't want anything besides these top-level includes.