Public Member Functions | List of all members
operations_research::KnapsackState Class Reference

--— KnapsackState --— KnapsackState represents a partial solution to the knapsack problem. More...

#include <knapsack_solver.h>

Public Member Functions

 KnapsackState ()
 
void Init (int number_of_items)
 Initializes vectors with number_of_items set to false (i.e. not bound yet). More...
 
bool UpdateState (bool revert, const KnapsackAssignment &assignment)
 Updates the state by applying or reverting a decision. More...
 
int GetNumberOfItems () const
 
bool is_bound (int id) const
 
bool is_in (int id) const
 

Detailed Description

--— KnapsackState --— KnapsackState represents a partial solution to the knapsack problem.

Definition at line 334 of file knapsack_solver.h.

Constructor & Destructor Documentation

◆ KnapsackState()

operations_research::KnapsackState::KnapsackState ( )

Member Function Documentation

◆ GetNumberOfItems()

int operations_research::KnapsackState::GetNumberOfItems ( ) const
inline

Definition at line 345 of file knapsack_solver.h.

◆ Init()

void operations_research::KnapsackState::Init ( int  number_of_items)

Initializes vectors with number_of_items set to false (i.e. not bound yet).

◆ is_bound()

bool operations_research::KnapsackState::is_bound ( int  id) const
inline

Definition at line 346 of file knapsack_solver.h.

◆ is_in()

bool operations_research::KnapsackState::is_in ( int  id) const
inline

Definition at line 347 of file knapsack_solver.h.

◆ UpdateState()

bool operations_research::KnapsackState::UpdateState ( bool  revert,
const KnapsackAssignment assignment 
)

Updates the state by applying or reverting a decision.

Returns false if fails, i.e. trying to apply an inconsistent decision to an already assigned item.


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