I have the following vectors (or C matrix and V vector) and K1, K2, K3 constants
Constraints [c11 + c12 + c13 + ... + c1n] <= K1
[c21 + c22 + c23 + ... + c2n] <= K2
[c31 + c32 + c33 + ... + c3n] <= K3
-------------------------------------------------
Values [ v1 + v2 + v3 + ... + vn] -> Max
As an input I am getting values of C and V, and as an output I want to provide the X vector which contains only 0 and 1 values and gives me
[c11 * x1 + c12 * x2 + c13 * x3 + ... + c1n * xn <= K1
[c21 * x1 + c22 * x2 + c23 * x3 + ... + c2n * xn <= K2
[c31 * x1 + c32 * x2 + c33 * x3 + ... + c3n * xn <= K3
------------------------------------------------------
[ v1 * x1 + v2 * x2 + v3 * x3 + ... + vn * xn] -> Max
As an over simplified example:
Input:
K1 = 15
K2 = 20
K3 = 10
c1 = [3, 6, 8] | sum(c1 * X) <= 15
c2 = [8, 9, 3] | sum(c2 * X) <= 20
c3 = [7, 5, 2] | sum(c3 * x) <= 10
v = [2, 5, 3] | sum( v * X) -> Max
Output providing X vector which is maximizing the value within the constrains:
X = [0, 1, 1]
I am looking for an elegant algorithm (may be a Java or C# implementation as well) giving me the output based on the input. We can assume that the number of constraints is always 3 and all values of C and V (and K1, K2, K3) are provided.
Another simple example could be: You have a room (3D), so your constraints are the width, height and length of the room (K1, K2, K3) and you have a list of furniture items (n items). All i furniture item has it's own lenght (c1i), width (c2i) and height (c3i) and value (vi). You want to pack the room with the most valuable furniture items which fits inside the rooms dimensions. So the output is an n-long X variable which contains only 0 and 1 values, if xi = 1, the i-th element gets picked to be in the room, if xi = 0 the ith element won't be picked to be in the room.