In a constrained optimization if "beq" is a matrix with a variable, then how to plot the variable in "beq" and the objective function?

I want to have plot of variable (m) value and objective function values (-fval) in "x","y" axis respectively, I can evaluate the values of "fval" but can't plot the desired results.
Following is my working programme:
fun = @(x)sum((x.*(log(x))));
A = [];
b = [];
x0 = [1/6 1/6 1/6 1/6 1/6 1/6];
lb = [0,0,0,0,0,0];
ub = [1,1,1,1,1,1];
Aeq = [1,1,1,1,1,1;1,2,3,4,5,6];
for m=1:0.5:6;
beq = [1;m];
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
plot(m,-fval);
end

12 Comments

What difficulty you facing? What is your problem or error?
Dear sir, I am not getting any plot after running the MATLAB code, which I have provided.
@Amritansu, have you tried the code I gave in the answer?
@Ameer, sorry for replying late. I am outside and don't have computer with me. I will surely run the code as early as possible when I am get back home. Thank you in advance for your help.
@Ameer,suppose the variable "m" is a triangular fuzzy number(TFN) then to write the codes what can be done? Can you suggest me anything?
It depends on how you want to use triangular fuzzy numbers here. If m is just a numeric vector then there is no difference.
@Ameer, suppose m=TFN(1.75/3/4). So we will have sub-problems as below and the programme code will have two equation and there will be two solution.The best solution will be considered. Thank you again for your interest.
The problem is still not quite clear. You have three values in m, and those are also shown on the x-axis. What are the values on the y-axis? From these two lines, what is the solution which you want?
well a TFN or triangular fuzzy number (a/b/c) denotes three values a=most pessimistic,b=most common and c=most optimistic. A TFN is defined as below
(a/b/c)=(x-a)/(b-a), when x belongs to [a.b]
=(x-c)/(b-c), when x belongs to [b.c]
=0, otherwise
So (1.75,3,4) will have two branches.And as a result the fval has two values and one is better.One thing to remember that here m is not increasing like m=1:0.5:6 ;so only one functional value will be found for each TFN. I hope I can write the codes, otherwise I will seek help from community. Thanks for your queries.
To make the things simple, can you tell what value will m take in first and second subproblem? In first subproblem, the x change from [1.75, 3] and y from [0, 1]. So what does it mean to find the solution of the first subproblem? What are the values of m for which we need to optimize the objective function?
@Ameer,when we use beq = [1;m];where m=a triangular fuzzy number then then the given problem is a fuzzy optimisation problem and we generally set fuzzy goals for objective functions and also for the constraint related to fuzzy value. I know I am not able make you understand this but thank you very much for immense help regarding the code.

Sign in to comment.

 Accepted Answer

You are not saving all the values of fval. Try this
fun = @(x)sum((x.*(log(x))));
A = [];
b = [];
x0 = [1/6 1/6 1/6 1/6 1/6 1/6];
lb = [0,0,0,0,0,0];
ub = [1,1,1,1,1,1];
Aeq = [1,1,1,1,1,1;1,2,3,4,5,6];
m=1:0.5:6;
fval = zeros(1, numel(m));
for ii=1:numel(m)
beq = [1;m(ii)];
[x,fval(ii)] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
end
plot(m,-fval);

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!