forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIHeuristicKnapsackSolver.cs
25 lines (24 loc) · 1.03 KB
/
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
25
using System;
namespace Algorithms.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>
public interface IHeuristicKnapsackSolver<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, double capacity, Func<T, double> weightSelector, Func<T, double> valueSelector);
}
}