OR-Tools  8.2
integral_solver.h
Go to the documentation of this file.
1// Copyright 2010-2018 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 "ortools/bop/bop_parameters.pb.h"
21
22namespace operations_research {
23namespace bop {
24// This class implements an Integer Programming solver, i.e. the solver solves
25// problems with both integral and boolean variables, linear constraint and
26// linear objective function.
28 public:
31
32 // Sets the solver parameters.
33 // See the proto for an extensive documentation.
34 void SetParameters(const BopParameters& parameters) {
35 parameters_ = parameters;
36 }
37 BopParameters parameters() const { return parameters_; }
38
39 // Solves the given linear program and returns the solve status.
40 ABSL_MUST_USE_RESULT BopSolveStatus
41 Solve(const glop::LinearProgram& linear_problem);
42 ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(
43 const glop::LinearProgram& linear_problem, TimeLimit* time_limit);
44
45 // Same as Solve() but starts from the given solution.
46 // TODO(user): Change the API to accept a partial solution instead since the
47 // underlying solver supports it.
48 ABSL_MUST_USE_RESULT BopSolveStatus
49 Solve(const glop::LinearProgram& linear_problem,
50 const glop::DenseRow& user_provided_initial_solution);
51 ABSL_MUST_USE_RESULT BopSolveStatus
53 const glop::DenseRow& user_provided_initial_solution,
55
56 // Returns the objective value of the solution with its offset.
57 glop::Fractional objective_value() const { return objective_value_; }
58
59 // Returns the best bound found so far.
60 glop::Fractional best_bound() const { return best_bound_; }
61
62 // Returns the solution values. Note that the values only make sense when a
63 // solution is found.
64 const glop::DenseRow& variable_values() const { return variable_values_; }
65
66 private:
67 BopParameters parameters_;
68 glop::DenseRow variable_values_;
69 glop::Fractional objective_value_;
70 glop::Fractional best_bound_;
71
72 DISALLOW_COPY_AND_ASSIGN(IntegralSolver);
73};
74} // namespace bop
75} // namespace operations_research
76#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:105
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)
SharedTimeLimit * time_limit
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...