- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathIHeuristicKnapsackSolver.cs
24 lines (22 loc) · 968 Bytes
/
IHeuristicKnapsackSolver.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
usingSystem;
namespaceAlgorithms.Knapsack;
/// <summary>
/// Solves knapsack problem using some heuristics
/// Sum of values of taken items -> max
/// Sum of weights of taken items. <= capacity.
/// </summary>
/// <typeparam name="T">Type of items in knapsack.</typeparam>
publicinterfaceIHeuristicKnapsackSolver<T>
{
/// <summary>
/// Solves knapsack problem using some heuristics
/// Sum of values of taken items -> max
/// Sum of weights of taken items. <= capacity.
/// </summary>
/// <param name="items">All items to choose from.</param>
/// <param name="capacity">How much weight we can take.</param>
/// <param name="weightSelector">Maps item to its weight.</param>
/// <param name="valueSelector">Maps item to its value.</param>
/// <returns>Items that were chosen.</returns>
T[]Solve(T[]items,doublecapacity,Func<T,double>weightSelector,Func<T,double>valueSelector);
}