OR-Tools  9.3
integral_solver.h
Go to the documentation of this file.
1// Copyright 2010-2021 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/port.h"
18#include "ortools/bop/bop_parameters.pb.h"
22
23namespace operations_research {
24namespace bop {
25// This class implements an Integer Programming solver, i.e. the solver solves
26// problems with both integral and boolean variables, linear constraint and
27// linear objective function.
29 public:
32
33 // Sets the solver parameters.
34 // See the proto for an extensive documentation.
35 void SetParameters(const BopParameters& parameters) {
36 parameters_ = parameters;
37 }
38 BopParameters parameters() const { return parameters_; }
39
40 // Solves the given linear program and returns the solve status.
41 ABSL_MUST_USE_RESULT BopSolveStatus
42 Solve(const glop::LinearProgram& linear_problem);
43 ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(
44 const glop::LinearProgram& linear_problem, TimeLimit* time_limit);
45
46 // Same as Solve() but starts from the given solution.
47 // TODO(user): Change the API to accept a partial solution instead since the
48 // underlying solver supports it.
49 ABSL_MUST_USE_RESULT BopSolveStatus
50 Solve(const glop::LinearProgram& linear_problem,
51 const glop::DenseRow& user_provided_initial_solution);
52 ABSL_MUST_USE_RESULT BopSolveStatus
54 const glop::DenseRow& user_provided_initial_solution,
56
57 // Returns the objective value of the solution with its offset.
58 glop::Fractional objective_value() const { return objective_value_; }
59
60 // Returns the best bound found so far.
61 glop::Fractional best_bound() const { return best_bound_; }
62
63 // Returns the solution values. Note that the values only make sense when a
64 // solution is found.
65 const glop::DenseRow& variable_values() const { return variable_values_; }
66
67 private:
68 BopParameters parameters_;
69 glop::DenseRow variable_values_;
70 glop::Fractional objective_value_;
71 glop::Fractional best_bound_;
72
73 DISALLOW_COPY_AND_ASSIGN(IntegralSolver);
74};
75} // namespace bop
76} // namespace operations_research
77#endif // OR_TOOLS_BOP_INTEGRAL_SOLVER_H_
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
Definition: time_limit.h:106
ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(const glop::LinearProgram &linear_problem, TimeLimit *time_limit)
ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(const glop::LinearProgram &linear_problem, const glop::DenseRow &user_provided_initial_solution, TimeLimit *time_limit)
glop::Fractional objective_value() const
ABSL_MUST_USE_RESULT BopSolveStatus Solve(const glop::LinearProgram &linear_problem, const glop::DenseRow &user_provided_initial_solution)
ABSL_MUST_USE_RESULT BopSolveStatus Solve(const glop::LinearProgram &linear_problem)
const glop::DenseRow & variable_values() const
void SetParameters(const BopParameters &parameters)
ModelSharedTimeLimit * time_limit
Collection of objects used to extend the Constraint Solver library.