Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::BaseKnapsackSolver Class Referenceabstract

#include <knapsack_solver.h>

Inheritance diagram for operations_research::BaseKnapsackSolver:
operations_research::Knapsack64ItemsSolver operations_research::KnapsackBruteForceSolver operations_research::KnapsackCpSat operations_research::KnapsackDivideAndConquerSolver operations_research::KnapsackDynamicProgrammingSolver operations_research::KnapsackGenericSolver operations_research::KnapsackMIPSolver

Public Member Functions

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

Detailed Description

--— BaseKnapsackSolver --— This is the base class for knapsack solvers.

Definition at line 606 of file knapsack_solver.h.

Constructor & Destructor Documentation

◆ BaseKnapsackSolver()

operations_research::BaseKnapsackSolver::BaseKnapsackSolver ( absl::string_view solver_name)
inlineexplicit

Definition at line 608 of file knapsack_solver.h.

◆ ~BaseKnapsackSolver()

virtual operations_research::BaseKnapsackSolver::~BaseKnapsackSolver ( )
virtualdefault

Member Function Documentation

◆ best_solution()

virtual bool operations_research::BaseKnapsackSolver::best_solution ( int item_id) const
pure virtual

◆ GetLowerAndUpperBoundWhenItem()

void operations_research::BaseKnapsackSolver::GetLowerAndUpperBoundWhenItem ( int item_id,
bool is_item_in,
int64_t * lower_bound,
int64_t * upper_bound )
virtual

--— BaseKnapsackSolver --—

Gets the lower and upper bound when the item is in or out of the knapsack. To ensure objects are correctly initialized, this method should not be called before Init.

Reimplemented in operations_research::KnapsackGenericSolver.

Definition at line 1650 of file knapsack_solver.cc.

◆ GetName()

virtual std::string operations_research::BaseKnapsackSolver::GetName ( ) const
inlinevirtual

Definition at line 631 of file knapsack_solver.h.

◆ Init()

virtual void operations_research::BaseKnapsackSolver::Init ( const std::vector< int64_t > & profits,
const std::vector< std::vector< int64_t > > & weights,
const std::vector< int64_t > & capacities )
pure virtual

◆ Solve()

virtual int64_t operations_research::BaseKnapsackSolver::Solve ( TimeLimit * time_limit,
double time_limit_in_seconds,
bool * is_solution_optimal )
pure virtual

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