OR-Tools  8.1
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 
18 #include "ortools/bop/bop_types.h"
21 
22 namespace operations_research {
23 namespace 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
52  SolveWithTimeLimit(const glop::LinearProgram& linear_problem,
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_
operations_research::bop::IntegralSolver::SetParameters
void SetParameters(const BopParameters &parameters)
Definition: integral_solver.h:34
time_limit.h
lp_data.h
operations_research::bop::IntegralSolver
Definition: integral_solver.h:27
operations_research::bop::IntegralSolver::~IntegralSolver
~IntegralSolver()
Definition: integral_solver.h:30
operations_research::bop::IntegralSolver::objective_value
glop::Fractional objective_value() const
Definition: integral_solver.h:57
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition: dense_doubly_linked_list.h:21
operations_research::TimeLimit
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
Definition: time_limit.h:105
operations_research::bop::IntegralSolver::variable_values
const glop::DenseRow & variable_values() const
Definition: integral_solver.h:64
operations_research::glop::Fractional
double Fractional
Definition: lp_types.h:77
time_limit
SharedTimeLimit * time_limit
Definition: cp_model_solver.cc:2103
bop_types.h
operations_research::glop::StrictITIVector< ColIndex, Fractional >
operations_research::bop::IntegralSolver::SolveWithTimeLimit
ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(const glop::LinearProgram &linear_problem, TimeLimit *time_limit)
operations_research::bop::IntegralSolver::parameters
BopParameters parameters() const
Definition: integral_solver.h:37
operations_research::bop::IntegralSolver::Solve
ABSL_MUST_USE_RESULT BopSolveStatus Solve(const glop::LinearProgram &linear_problem, const glop::DenseRow &user_provided_initial_solution)
operations_research::bop::IntegralSolver::SolveWithTimeLimit
ABSL_MUST_USE_RESULT BopSolveStatus SolveWithTimeLimit(const glop::LinearProgram &linear_problem, const glop::DenseRow &user_provided_initial_solution, TimeLimit *time_limit)
operations_research::glop::LinearProgram
Definition: lp_data.h:55
bop_parameters.pb.h
operations_research::bop::IntegralSolver::Solve
ABSL_MUST_USE_RESULT BopSolveStatus Solve(const glop::LinearProgram &linear_problem)
operations_research::bop::BopSolveStatus
BopSolveStatus
Definition: bop_types.h:31
operations_research::bop::IntegralSolver::IntegralSolver
IntegralSolver()
Definition: integral_solver.cc:1039
operations_research::bop::IntegralSolver::best_bound
glop::Fractional best_bound() const
Definition: integral_solver.h:60