Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::KnapsackCpSat Class Reference

--— KnapsackCpSat --— More...

Inheritance diagram for operations_research::KnapsackCpSat:
operations_research::BaseKnapsackSolver

Public Member Functions

 KnapsackCpSat (absl::string_view solver_name)
 
void Init (const std::vector< int64_t > &profits, const std::vector< std::vector< int64_t > > &weights, const std::vector< int64_t > &capacities) override
 Initializes the solver and enters the problem to be solved.
 
int64_t Solve (TimeLimit *time_limit, double time_limit_in_seconds, bool *is_solution_optimal) override
 Solves the problem and returns the profit of the optimal solution.
 
bool best_solution (int item_id) const override
 Returns true if the item 'item_id' is packed in the optimal knapsack.
 
- Public Member Functions inherited from operations_research::BaseKnapsackSolver
 BaseKnapsackSolver (absl::string_view solver_name)
 
virtual ~BaseKnapsackSolver ()=default
 
virtual void GetLowerAndUpperBoundWhenItem (int item_id, bool is_item_in, int64_t *lower_bound, int64_t *upper_bound)
 --— BaseKnapsackSolver --—
 
virtual std::string GetName () const
 

Detailed Description

--— KnapsackCpSat --—

Definition at line 1284 of file knapsack_solver.cc.

Constructor & Destructor Documentation

◆ KnapsackCpSat()

operations_research::KnapsackCpSat::KnapsackCpSat ( absl::string_view solver_name)
explicit

Definition at line 1309 of file knapsack_solver.cc.

Member Function Documentation

◆ best_solution()

bool operations_research::KnapsackCpSat::best_solution ( int item_id) const
inlineoverridevirtual

Returns true if the item 'item_id' is packed in the optimal knapsack.

Implements operations_research::BaseKnapsackSolver.

Definition at line 1298 of file knapsack_solver.cc.

◆ Init()

void operations_research::KnapsackCpSat::Init ( const std::vector< int64_t > & profits,
const std::vector< std::vector< int64_t > > & weights,
const std::vector< int64_t > & capacities )
overridevirtual

Initializes the solver and enters the problem to be solved.

Implements operations_research::BaseKnapsackSolver.

Definition at line 1316 of file knapsack_solver.cc.

◆ Solve()

int64_t operations_research::KnapsackCpSat::Solve ( TimeLimit * time_limit,
double time_limit_in_seconds,
bool * is_solution_optimal )
overridevirtual

Solves the problem and returns the profit of the optimal solution.

Add constraints.

Define objective to maximize.

Store best solution.

Implements operations_research::BaseKnapsackSolver.

Definition at line 1324 of file knapsack_solver.cc.


The documentation for this class was generated from the following file: