Trouble with my homework - Getting an error in my linear programming code requiring a double.

조회 수: 1 (최근 30일)
options=optimoptions(@linprog,'Algorithm','dual-simplex');
f=[110;220;250;140];
A=[2/3,1,5/8,5/6;0,1,6/5,3/4;0,1,1/2,0;0,0,0,1];
ub=[10000;150000;8000;7000];
lb=zeros(4,1);
[x,fval,exitflag,output,lambda] = ...
linprog((f,A,ub,[],[],lb,options)
Error using linprog
LINPROG requires the following inputs to be of data type double: 'UB'.
Error in ProfitMax (line 7)
linprog(f,A,ub,[],[],lb,options)
running the following to maximise profits
110x1 + 220x2 + 250x3 +140x4
on the following
2/3x1 + 1x2 + 5/8x3 + 5/6x4 <= 10000
0x1 + 1x2 + 6/5x3 + 3/4x4 <= 15000
0x1 + 1x2 + 1/2x3 + 0x4 <= 8000
0x1 + 0x2 + 0x3 + 1x4 <= 7000
And should I be using dual simplex or interior point - why does this matter?
  댓글 수: 2
Image Analyst
Image Analyst 2022년 8월 5일
It looks like everything is a double except for the nulls. What are those supposed to be? Is it okay if they're null?
Scott
Scott 2022년 8월 5일
They were in the example code provided by the lecturer. If I delete them the error code changes to
Error using linprog
LINPROG requires the following inputs to be of data type double: 'beq'.
Error in ProfitMax (line 7)
linprog(f,A,ub,lb,options)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2022년 8월 5일
linprog((f,A,ub,[],[],lb,options)
You missed passing ub in. Your options are in the ub slot.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 8월 5일
Note that you cannot pass values in any order you like. MATLAB does not look at the names of the variables you pass in to decide what function the parameter should have: MATLAB requires a very specific order:
f_Matrix, Linear_Inequality_A, Linear_Inequality_b, Linear_Equality_A, Linear_Equality_b, Lower_Bound, UpperBound, Initial_Guess, Options

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by