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