Clear Filters
Clear Filters

To know the Exact Code Please To Run this Example: (optimization linprog)

4 views (last 30 days)
Dear Eng.
I'm trying to solve this attached problem as Assignment using linprog Code
Then it will be solved through:
h(1) = 0.6
h(2) =0.8
h(3) =1
g(1) =0.1
g(2) =0.2
g(3) =0.3
C Matrix
C = [1
1
1]
A Matrix (3*3)
A= [h(1) - g(1)h(2) -g(3)h(3)
-g(2)h(1) h(2) -g(2)h(3)
-g(3)h(1) -g(3)h(2) h(3)]
b Matrix
b = [0
0
0]
Assuming Values for h's and Gamma's as shown above
Do you think we'll need Upper limit and Lower Limit for this example?
I need the correct Matlab Linprog Code to run please?
Thanks alot for your cooperation
I
  7 Comments
Dalia ElNakib
Dalia ElNakib on 4 May 2023
h(1) = 0.6;
h(2) = 0.8;
h(3) = 1;
g(1) = 0.1;
g(2) = 0.2;
g(3) = 0.3;
%c Matrix
c = [1; 1; 1];
%A Matrix (3*3)
A = [h(1) -g(1)*h(2) -g(3)*h(3);-g(2)*h(1) h(2) -g(2)*h(3);-g(3)*h(1) -g(3)*h(2) h(3)];
%b Matrix
b = [0; 0 ;0];
%Bound constraint
lb = [0.0000003; 0.0000003; 0.0000003];
ub = [1000 ;1000 ;1000];
%Solve
p = linprog(c,A,b,[],[],lb,ub);
Optimal solution found.
Torsten
Torsten on 4 May 2023
Edited: Torsten on 4 May 2023
No, my code from above was correct (using -A and -b).
I only wanted to point out that for linprog, it's necessary to pass -A and -b because the inequality is reversed compared to your problem formulation.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!