help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is error(19) or error(15): out of bound(1)...how to resolve?


From: Satyaballi
Subject: Re: What is error(19) or error(15): out of bound(1)...how to resolve?
Date: Sun, 28 Oct 2018 14:05:02 -0500 (CDT)

Hi 
thank you for your reply.  But in my code, I've defined 'x' to be 4x1
matrix.  Where is the problem?

please help me resolve this.

My code is:

*clear all;
format short e;

% global variable declaration for all constants
global P=6000 L=14 E=30e6 Delmax=0.25 G=12e6 Taumax=13.6e3 Sigmax=30e3;

%defining initial values, limiting values, max no.of iterations and
tolerance
x0=[0.5;10;0.5;1];
lb=[0.125; 0.1; 0.01; 0.01];
ub=[inf; inf; 10; 2];
maxiter=1000;
tol=1e-8;

%defining objective function
function obj=f(x)
  obj=1.10471*x(1)^2*x(2)+0.04811*x(3)*x(4)*(14+x(2));
endfunction

%definging gradient of objective function
function gradf=df(x)
 
gradf=[2.20942*x(1)*x(2);1.10471*x(1)^2+0.04811*x(3)*x(4);0.04811*x(4)*(14+x(2));
         0.04811*x(3)*(14+x(2))];
endfunction

%defining Hessian of objective function
function Hessobj=ddf(x)
  Hessobj=[2.20942*x(2) 2.20942*x(1) 0 0;2.20942*x(1) 0 0.04811*x(4)
0.04811*x(3);
           0 0.04811*x(4) 0 0.04811*(14+x(2));0 0.04811*x(3)
0.04811*(14+x(2)) 0];
endfunction

%defining constraints
function ineqcons=g(x)
  global P L E Delmax G Taumax Sigmax;
  %display(Taumax);
  Tau1=P/(sqrt(2)*x(1)*x(2));
  M=P*(L+x(2)/2);
  R=sqrt(x(2)^2/4+((x(1)+x(3))/2)^2);
  J=2*sqrt(2)*x(1)*x(2)*(x(2)^2/12+((x(1)+x(3))/2)^2);
  Tau2=M*R/J;
  Tau=sqrt(Tau1^2+Tau1*M*x(2)/J+Tau2^2);
  Sigma=6*P*L/(x(4)*x(3)^2);
  Delta=4*P*L^3/(E*x(3)^3*x(4));
  Pc=(4.103*E/L^2)*(x(3)*x(4)^3/6)*(1-(x(3)/2*L)*sqrt(E/(4*G)));
  ineqcons=[-(Tau-Taumax); -(Sigma-Sigmax); -(x(1)-x(4)); -(Delta-Delmax);
-(0.10471*x(1)^2+0.04811*x(3)*x(4)(14+x(2))-5); -(P-Pc)];
endfunction

%Supplying Objective function including Gradient and Hessian 
Objfun={@(x)f(x),@(x)df(x),@(x)ddf(x)};

[x,obj,info,iter,nf,lambda] = ...*
sqp(x0,Objfun,[],@(x)g(x),lb,ub, maxiter, tol)




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]