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

This is the base class for knapsack solvers. More...

Detailed Description

This is the base class for knapsack solvers.

Definition at line 579 of file knapsack_solver.h.

#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)
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

Constructor & Destructor Documentation

◆ BaseKnapsackSolver()

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

Definition at line 581 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

Reimplemented in operations_research::KnapsackGenericSolver.

Definition at line 1644 of file knapsack_solver.cc.

◆ GetName()

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

Definition at line 604 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: