-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
BranchAndBoundNode.cs
29 lines (22 loc) · 1 KB
/
BranchAndBoundNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace Algorithms.Knapsack;
public class BranchAndBoundNode
{
// isTaken --> true = the item where index = level is taken, vice versa
public bool IsTaken { get; }
// cumulativeWeight --> um of weight of item associated in each nodes starting from root to this node (only item that is taken)
public int CumulativeWeight { get; set; }
// cumulativeValue --> sum of value of item associated in each nodes starting from root to this node (only item that is taken)
public double CumulativeValue { get; set; }
// upperBound --> largest possible value after taking/not taking the item associated to this node (fractional)
public double UpperBound { get; set; }
// level --> level of the node in the tree structure
public int Level { get; }
// parent node
public BranchAndBoundNode? Parent { get; }
public BranchAndBoundNode(int level, bool taken, BranchAndBoundNode? parent = null)
{
Level = level;
IsTaken = taken;
Parent = parent;
}
}