My Project
Public Member Functions | Public Attributes | List of all members
StarCastRecommend.Knap Class Reference

Public Member Functions

def __init__ (self, weights, total, profit)
 Constructor used to initialize variables used everywhere in the function. More...
 
def getItemsUsed (self)
 Once the table of the Knapsack Algorithm is constructed, this function can be used to determine which actors were used to get this table. More...
 
def algorithm (self)
 This function is used to compute the table in the Knapsack Algorithm. More...
 

Public Attributes

 weights
 Contains cost of picking each element. More...
 
 total
 Contains total weight of bag allowed. More...
 
 profit
 Profit associated with picking an element.
 
 n
 Number of elements to be picked from.
 
 selected
 A matrix of size N X (W + 1)
 
 marked
 Boolean List which will indicate which actor is selected after doing 0/1 knapsack. More...
 

Detailed Description

Class used for Knapsack implementation. \ Consists of two functions used for computing table, and one for evaluating which actors were chosen to create the table.

Constructor & Destructor Documentation

◆ __init__()

def StarCastRecommend.Knap.__init__ (   self,
  weights,
  total,
  profit 
)

Constructor used to initialize variables used everywhere in the function.

Parameters
weightsCost of each actor is stored in this list.
totalThis variable is used to denote the total budget.
profitThis list indicates the profit of choosing an actor.

Member Function Documentation

◆ algorithm()

def StarCastRecommend.Knap.algorithm (   self)

This function is used to compute the table in the Knapsack Algorithm.

This table self.selected indicates the best profit for a set of actors.

Returns
List containing the maximum profit, and the set of actors used to get this profit

◆ getItemsUsed()

def StarCastRecommend.Knap.getItemsUsed (   self)

Once the table of the Knapsack Algorithm is constructed, this function can be used to determine which actors were used to get this table.

Returns
Set of actors (in 0s and 1s) that maximize profit and keep the total cost in the budget as determined by Knapsack.

Member Data Documentation

◆ marked

StarCastRecommend.Knap.marked

Boolean List which will indicate which actor is selected after doing 0/1 knapsack.

◆ total

StarCastRecommend.Knap.total

Contains total weight of bag allowed.

◆ weights

StarCastRecommend.Knap.weights

Contains cost of picking each element.


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