While running a optimization technique i am facing solver error
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Derivative of state '1' in block 'pialo4/ITAE/Integrator' at time 79.983828232694961 is not finite. The
simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step
size (either by reducing the fixed step size or by tightening the error tolerances)
2 Commenti
Benjamin Thompson
il 15 Feb 2022
Is there a singularity in the function you are optimizing at this time (79.98 seconds)? Is the message accurate about the problem the solver is encountering? Can you post any information like code for the Community to look at?
Risposte (1)
Chandini Kollati
il 6 Set 2022
Clc
Clear
format short
%%%%%% Stage 1: %%%%%%%%
C= [3 5];
A= [ 1 2 ; 1 1 ; 0 1 ];
b= [2000; 1500; 600];
%%%%%%%%% Stage 2: ploting the constraints in 2d graph%%%%%%%%%%
y1= 0:1: max(b);
x21= (b(1) - A(1,1) .*y1)./A(1,2);
X22= (b(2) - A(2,1) .*y1)./A(2,2);
X23= (b(3) - A(3,1) .*y1)./A(3,2);
X21= max(0,X21);
X22= max(0,X22);
X23= max(0,X23);
plot(y1,X21, 'r', y1,X22,'k', y1, X23, 'b');
xlabel( 'value of x1');
ylabel( 'value of x2');
title('x1 vs x2');
legend('x1+2x2=2000', ' x1+x2=1500', 'x2=600')
%%%%%%%%%%%%Phase 3 Find the corner point i.e., pt of intersections
Cx1=find(y1==0);
C1 = find(X21==0);
Line1= [y1(:, [C1 Cx1]) ; X21(:, [C1 Cx1])]';
C2 = find(X22==0);
Line2= [y1(:, [C2 Cx1]) ; X22(:, [C2 Cx1])]';
C3 = find(X23==0);
Line3= [y1(:, [C3 Cx1]) ; X23(:, [C3 Cx1])]';
Corpt= unique([Line1;Line2;Line3],'row');
%%%%%%%%Stage 4 Find the intersection points%%%%%%%%
HG=[0;0];
for i=1:size(A,1)
Hg1=A(i,: );
B1=b(i,: ) ;
for j=i+1: size(A,1)
Hg2= A(j,: );
B2= b (j, : );
Aa= [Hg1; Hg2];
Bb= [B1;B2];
Xx= Aa\Bb;
HG=[ HG Xx];
end
end
Pt = HG';
%%%%%%%%%%%%%%%% Stage 5 write all points, i.e., corner + intersection points ********
Allpt = [Pt; Corpt];
%%%%%%%%%%%%%%% stage 6: find the feasible region %%%%%%%%%
PT= constraint(Allpt);
PT= unique(PT,'row');
%%%%%%% stage 7*************
for i=1: size(PT,1)
FX(i, : ) = sum (PT (i,: ).*C);
End
%%%%%%%% final Stage optimal Solution %%%%%%%%%%%
vert_fns = [PT FX];
[fxval, indfx]= max(FX);
optval = vert_fns(indfx, :);
optimal_bfs= array2table( Optval);
disp(" x value is")
disp(optimal_bfs(1,[1]))
disp("y value is")
disp(optimal_bfs(1,[1]))
disp("max value is")
disp(optimal_bfs(1,[1]))
function X = constraint(X)
%%%%%%% write the first constraint here%%%%%%%
X1= X(: , 1);
X2= X(: , 2);
Cons1 = X1+2.*X2-2000;
H1=find(Cons1>0);
X(H1,: )=[];
%%%%%%% write the Second constraint here%%%%%%%
X1= X(: , 1);
X2= X(: , 2);
Cons2 = X1+X2-1500;
H2=find(Cons2>0);
X(H2,: )=[];
%%%%%%% write the Third constraint here%%%%%%%
X1= X(: , 1);
X2= X(: , 2);
Cons3 = X2-1500;
H3=find(Cons3>0);
X(H3,: )=[];
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!