why Fmincon code result are infeasible
    3 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Elmira Jafari
 il 15 Dic 2021
  
    
    
    
    
    Commentato: Elmira Jafari
 il 15 Dic 2021
            Hello,
I dont know why the code for fmincon does not attention to linear constraint A, b and the results that gives me is obviously infeasible.
In A the first element asks t1 has to be larger than 1 but the result gives me t1=0.3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Wheelchair
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Wheelchair
%     clc;
    clear all; close all;
    dp=design_parameters; % Generate structure variable containing all design parameters
    f=@(x)objective_function(x,dp); % Objective function handle
    nonlcon=@(x)nonlinear_constraints(x,dp); % Nonlinear constraint function handle
    lb=[dp.X1_min;dp.X2_min;dp.X3_min;dp.X4_min];% Design variable bounds
    ub=[dp.X1_max;dp.X2_max;dp.X3_max;dp.X4_max]; % Design variable bounds
    x0=[16e-3;0.8e-3;12e-3;0.7e-3]; % Initial design point
    A=[0,-(0.68*dp.db*dp.sigmau)/(0.3*dp.mb*dp.g),0,0;-1/dp.X1_min,0,0,0;1/dp.X1_max,0,0,0;0,-1/dp.X2_min,0,0;0,1/dp.X2_max,0,0;0,0,-1/dp.X3_min,0;0,0,1/dp.X3_max,0;0,0,0,-1/dp.X4_min;0,0,0,1/dp.X4_max];
    b=[-1,-1,1,-1,1,-1,1,-1,1];
    % Minimization using fmincon and the specified options:
    options=optimoptions('fmincon','Display','iter','OptimalityTolerance',1e-12,'ConstraintTolerance',1e-6,'StepTolerance',1e-12);
    [x,fval]=fmincon(f,x0,A,b,[],[],lb,ub,nonlcon,options);
    % Display of the optimal design results:
    disp(['Optimal value of d1: ',num2str(1000*x(1)),' mm']);
    disp(['Optimal value of t1: ',num2str(1000*x(2)),' mm']);
    disp(['Optimal value of d2: ',num2str(1000*x(3)),' mm']);
    disp(['Optimal value of t2: ',num2str(1000*x(4)),'mm']);
     disp(['Optimal value of f: ',num2str(fval),' kg']);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dp=design_parameters
    dp.L1=0.82; %(m)
    dp.L2=0.691; %(m)
    dp.L3=0.270; %(m)
    dp.L4=0.04; %(m)
    dp.L5=1.59; %(m)
    dp.L6=0.627; %(m)
    dp.L7=0.568; 
    dp.Lad=0.601; 
    dp.Lss=0.4; 
    dp.mb=300; 
    dp.Rho=2700; 
    dp.g=10;
    dp.db=6e-3; 
    dp.sigmau=110e6; 
    dp.E=68e9;
    dp.K=2.1; 
    dp.deltamax=1e-3; 
    dp.X1_min=14e-3; dp.X1_max=20e-3; % Minimum/maximum length of rectangular (mm)
    dp.X2_min=0.e-3; dp.X2_max=0.7e-3; %
    dp.X3_min=10e-3; dp.X3_max=14e-3; % 
    dp.X4_min=0.5e-3; dp.X4_max=0.7e-3; 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function f=objective_function(x,dp)
A1=(x(1)/2)^2-(x(1)/2-x(2))^2;
A2=(x(1)/2-x(2))^2-(x(1)/2-2*x(2))^2;
A3=((x(1)+2*x(2))^2-(x(1))^2)/4;
A4=(x(3)/2)^2-(x(3)/2-x(4))^2;
    f=2*((pi*A1*dp.L1*dp.Rho)+(pi*A1*dp.L2*dp.Rho)+(pi*A2*dp.L3*dp.Rho)+(6*pi*A3*dp.L4*dp.Rho)+(0.097))+((pi*A4*dp.L5*dp.Rho)+(pi*A4*dp.L6*dp.Rho)+(pi*A4*dp.L7*dp.Rho)); % 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [c,ceq]=nonlinear_constraints(x,dp)
A5=(x(1))^4-(x(1)-2*x(2))^4;
    c(10,1)=0.2*dp.mb*dp.g-((pi.^3* dp.E/(dp.K*dp.Lad)^2*64)*A5); % 
    c(11,1)=((dp.mb*dp.g/2)*(dp.Lss)^3/(48/64)*pi*A5)-dp.deltamax; % 
    ceq=[]; % There are no nonlinear equality constraints
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0 Commenti
Risposta accettata
  Matt J
      
      
 il 15 Dic 2021
        
      Modificato: Matt J
      
      
 il 15 Dic 2021
  
      There can't be any gaurantee that fmincon will be able to find a solution (for example, one may not exist), but fmincon is aware that a feasible solution was not found. This was made very clear in the  exit message:
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
4 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Quadratic Programming and Cone Programming 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!