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

#include <knapsack_solver.h>

Public Member Functions

 KnapsackState ()
 --— KnapsackState --—
 
 KnapsackState (const KnapsackState &)=delete
 This type is neither copyable nor movable.
 
KnapsackStateoperator= (const KnapsackState &)=delete
 
void Init (int number_of_items)
 Initializes vectors with number_of_items set to false (i.e. not bound yet).
 
bool UpdateState (bool revert, const KnapsackAssignment &assignment)
 Returns false when the state is invalid.
 
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 430 of file knapsack_solver.h.

Constructor & Destructor Documentation

◆ KnapsackState() [1/2]

operations_research::KnapsackState::KnapsackState ( )

--— KnapsackState --—

Definition at line 147 of file knapsack_solver.cc.

◆ KnapsackState() [2/2]

operations_research::KnapsackState::KnapsackState ( const KnapsackState & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ GetNumberOfItems()

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

Definition at line 447 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).

Definition at line 149 of file knapsack_solver.cc.

◆ is_bound()

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

Definition at line 448 of file knapsack_solver.h.

◆ is_in()

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

Definition at line 449 of file knapsack_solver.h.

◆ operator=()

KnapsackState & operations_research::KnapsackState::operator= ( const KnapsackState & )
delete

◆ UpdateState()

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

Returns false when the state is invalid.

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.

Definition at line 155 of file knapsack_solver.cc.


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