MILP code for maximisation

How to maximise the following:
(a*100)+(b*60)+(c*70)+(d*65)+(e*50)+(f*50)+(g*45)+(h*40)+(i*40)+(j*30)
with a constraint:
(a*61)+(b*28)+(c*33)+(d*30)+(e*25)+(f*17)+(g*25)+(h*12)+(i*16)+(j*10) is less than or equal 110.
knowing that a-j are either 0 or 1.
I tried to solve it using this code:
f = [100;60;70;65;50;50;45;40;40;30];
intcon = 10;
A = [61,28,33,30,25,17,25,12,16,10];
b = [110];
x = intlinprog(f,intcon,A,b)
but I got the following error:
>> tod308
Root LP problem is unbounded.
Intlinprog stopped because the root LP problem is unbounded.
x =
[]

Answers (1)

Matt J
Matt J on 1 May 2022
Edited: Matt J on 1 May 2022
lb=zeros(size(f));
x = intlinprog(-f,1:10,A,b,[],[],lb,lb+1);

2 Comments

I did what you told me and I got this in my commaned window:
LP: Optimal objective value is -278.571429.
Cut Generation: Applied 1 cover cut.
Lower bound is -275.000000.
Relative gap is 0.00%.
Optimal solution found.
Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon
variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).
However, I don't know what is the value for each A - j?
Matt J
Matt J on 1 May 2022
Edited: Matt J on 1 May 2022
Aren't you getting any output from intlinprog (aside from the screen messages)?

Sign in to comment.

Categories

Products

Release

R2018a

Asked:

on 1 May 2022

Edited:

on 1 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!