Reputation: 557
I'm having trouble with a question given to us by my professor:
A husband and wife are going on a trip and wish to maximise the benefit of bringing certain items with them. The husband can bring 20kgs and the wife can bring 17kgs. What should they bring?
This is what I have written and run using the 'lp_solve' linux command:
max 10 hs + 9 hl + 6 ha + 3 hb + 14 hr + 10 ws + 9 wl + 6 wa + 3 wb + 14 wr;
7 hs + 6 hl + 13 ha + 4 hb + 9 hr <= 20;
7 ws + 6 wl+ 13 wa + 4 wb + 9 wr <=17;
hs + ws <= 1;
hl + wl <= 1;
ha + wa <= 1;
hb + wb <= 1;
hr + wr <= 1;
bin hs,hl,ha,hb,hr,ws,wl,wa,wb,wr;
And this is my result:
My result show that the husband should take the stove and the axe while the wife should take the lamp and the binoculars. This is a valid result but it isn't the most beneficial... Can someone explain to me what I'm doing wrong?
Much appreciated.
Upvotes: 2
Views: 108
Reputation: 22506
Something very subtle is going on. You are missing a colon :
after the max
. So the lp_solver
thinks that max
is an unbounded variable. Your objective function value is what tipped me off.
Once you modify your Objective Function to:
max: 10 hs + 9 hl + 6 ha + 3 hb + 14 hr + 10 ws + 9 wl + 6 wa + 3 wb + 14 wr;
You will get the correct solution:
hs, ha, wl and wr will be 1.
Upvotes: 3