Public Member Functions | List of all members
operations_research::BaseKnapsackSolver Class Referenceabstract

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

#include <knapsack_solver.h>

Inheritance diagram for operations_research::BaseKnapsackSolver:
Inheritance graph
[legend]

Public Member Functions

 BaseKnapsackSolver (const std::string &solver_name)
 
virtual ~BaseKnapsackSolver ()
 
virtual void Init (const std::vector< int64 > &profits, const std::vector< std::vector< int64 > > &weights, const std::vector< int64 > &capacities)=0
 Initializes the solver and enters the problem to be solved. More...
 
virtual void GetLowerAndUpperBoundWhenItem (int item_id, bool is_item_in, int64 *lower_bound, int64 *upper_bound)
 Gets the lower and upper bound when the item is in or out of the knapsack. More...
 
virtual int64 Solve (TimeLimit *time_limit, bool *is_solution_optimal)=0
 Solves the problem and returns the profit of the optimal solution. More...
 
virtual bool best_solution (int item_id) const =0
 Returns true if the item 'item_id' is packed in the optimal knapsack. More...
 
virtual std::string GetName () const
 

Detailed Description

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

Definition at line 494 of file knapsack_solver.h.

Constructor & Destructor Documentation

◆ BaseKnapsackSolver()

operations_research::BaseKnapsackSolver::BaseKnapsackSolver ( const std::string &  solver_name)
inlineexplicit

Definition at line 496 of file knapsack_solver.h.

◆ ~BaseKnapsackSolver()

virtual operations_research::BaseKnapsackSolver::~BaseKnapsackSolver ( )
inlinevirtual

Definition at line 498 of file knapsack_solver.h.

Member Function Documentation

◆ best_solution()

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

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

Implemented in operations_research::KnapsackGenericSolver.

◆ GetLowerAndUpperBoundWhenItem()

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

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.

◆ GetName()

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

Definition at line 518 of file knapsack_solver.h.

◆ Init()

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

Initializes the solver and enters the problem to be solved.

Implemented in operations_research::KnapsackGenericSolver.

◆ Solve()

virtual int64 operations_research::BaseKnapsackSolver::Solve ( TimeLimit *  time_limit,
bool *  is_solution_optimal 
)
pure virtual

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

Implemented in operations_research::KnapsackGenericSolver.


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