diff --git a/26StoreyTruss.xls b/26StoreyTruss.xls new file mode 100644 index 0000000..b84cd23 Binary files /dev/null and b/26StoreyTruss.xls differ diff --git a/GWO.m b/GWO.m new file mode 100644 index 0000000..64aa2c3 --- /dev/null +++ b/GWO.m @@ -0,0 +1,125 @@ +% Grey Wold Optimizer (GWO) source codes version 1.1 % +% % +% Developed in MATLAB R2011b(7.13) % +% % +% Author and programmer: Seyedali Mirjalili % +% % +% e-Mail: ali.mirjalili@gmail.com % +% seyedali.mirjalili@griffithuni.edu.au % +% % +% Homepage: http://www.alimirjalili.com/GWO.html % +% % +% Main paper: S. Mirjalili, S. M. Mirjalili, A. Lewis % +% Grey Wolf Optimizer, Advances in Engineering % +% Software, Volume 69, March 2014, Pages 46-61, % +% http://dx.doi.org/10.1016/j.advengsoft.2013.12.007 % +% % + +% Grey Wolf Optimizer +function [Alpha_score,Alpha_pos,Convergence_curve]=GWO(SearchAgents_no,Max_iter,lb,ub,dim,fobj,handles,Value) + +% initialize alpha, beta, and delta_pos +Alpha_pos=zeros(1,dim); +Alpha_score=inf; %change this to -inf for maximization problems + +Beta_pos=zeros(1,dim); +Beta_score=inf; %change this to -inf for maximization problems + +Delta_pos=zeros(1,dim); +Delta_score=inf; %change this to -inf for maximization problems + +%Initialize the positions of search agents +Positions=initialization(SearchAgents_no,dim,ub,lb); + +%Convergence_curve=zeros(1,Max_iter); + +l=0;% Loop counter + +% Main loop +while lAlpha_score && fitnessAlpha_score && fitness>Beta_score && fitnessub; + Flag4lb=Positions(i,:)1 + line([l-1 l], [Convergence_curve(l-1) Convergence_curve(l)],'Color','b') + xlabel('Iteration'); + ylabel('Best score obtained so far'); + drawnow + end + + + set(handles.itertext,'String', ['The current iteration is ', num2str(l)]) + set(handles.optimumtext,'String', ['The current optimal value is ', num2str(Alpha_score)]) + if Value==1 + hold on + scatter(l*ones(1,SearchAgents_no),All_fitness,'.','k') + end +end + + + diff --git a/GWO_toolbox.fig b/GWO_toolbox.fig new file mode 100644 index 0000000..ca3323d Binary files /dev/null and b/GWO_toolbox.fig differ diff --git a/GWO_toolbox.m b/GWO_toolbox.m new file mode 100644 index 0000000..972bd57 --- /dev/null +++ b/GWO_toolbox.m @@ -0,0 +1,368 @@ +function varargout = GWO_toolbox(varargin) +% Grey Wold Optimizer (GWO) Tool box version 1.1 +% +% Developed in MATLAB R20121(7.14) +% +% Author and programmer: Seyedali Mirjalili +% +% e-Mail: ali.mirjalili@gmail.com +% seyedali.mirjalili@griffithuni.edu.au +% +% Homepage: http://www.alimirjalili.com/GWO.html +% +% Main paper: S. Mirjalili, S. M. Mirjalili, A. Lewis +% Grey Wolf Optimizer, Advances in Engineering +% Software, Volume 69, March 2014, Pages 46-61, +% http://dx.doi.org/10.1016/j.advengsoft.2013.12.007 +% +% +% You can simply define your cost function in a seperate file. +% The default name of the objective function is CostFunction. +% If you have a look at the CostFunction.m file, you may notice +% that the cost function gets the variables in a vector ([x1 x2 ... xn]) and +% returns the objective value. You can either write you objective function +% in this file or create a new file and pass its name to the toolbox. +% Remember to follow the same structure for input and output if you decided +% to go for the second option. +% +% The lower bounds and upper bounds of variables should also be witten as +% lb1,lb2,...,lbn and ub1,ub2,...,ubn +% +% If all of the variables have equal lower and/or upper bounds you can just +% define lb and ub as two single number numbers: lb, ub + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @GWO_toolbox_OpeningFcn, ... + 'gui_OutputFcn', @GWO_toolbox_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before GWO_toolbox is made visible. +function GWO_toolbox_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to GWO_toolbox (see VARARGIN) + +% Choose default command line output for GWO_toolbox +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes GWO_toolbox wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + + + + +% --- Outputs from this function are returned to the command line. +function varargout = GWO_toolbox_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; +labelStr = '
alimirjalili.com'; +cbStr = 'web(''http://www.alimirjalili.com'');'; +hButton = uicontrol('string',labelStr,'pos',[390,20,100,35],'callback',cbStr); + +labelStr = '
Find the paper'; +cbStr = 'web(''http://dx.doi.org/10.1016/j.advengsoft.2013.12.007'');'; +hButton = uicontrol('string',labelStr,'pos',[500,20,100,35],'callback',cbStr); + + + + +function WolfNo_Callback(hObject, eventdata, handles) +% hObject handle to WolfNo (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of WolfNo as text +% str2double(get(hObject,'String')) returns contents of WolfNo as a double + + +% --- Executes during object creation, after setting all properties. +function WolfNo_CreateFcn(hObject, eventdata, handles) +% hObject handle to WolfNo (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function IterNo_Callback(hObject, eventdata, handles) +% hObject handle to IterNo (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of IterNo as text +% str2double(get(hObject,'String')) returns contents of IterNo as a double + + +% --- Executes during object creation, after setting all properties. +function IterNo_CreateFcn(hObject, eventdata, handles) +% hObject handle to IterNo (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function LowerBound_Callback(hObject, eventdata, handles) +% hObject handle to LowerBound (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of LowerBound as text +% str2double(get(hObject,'String')) returns contents of LowerBound as a double + + +% --- Executes during object creation, after setting all properties. +function LowerBound_CreateFcn(hObject, eventdata, handles) +% hObject handle to LowerBound (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function UpperBound_Callback(hObject, eventdata, handles) +% hObject handle to UpperBound (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of UpperBound as text +% str2double(get(hObject,'String')) returns contents of UpperBound as a double + + +% --- Executes during object creation, after setting all properties. +function UpperBound_CreateFcn(hObject, eventdata, handles) +% hObject handle to UpperBound (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function Dim_Callback(hObject, eventdata, handles) +% hObject handle to Dim (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of Dim as text +% str2double(get(hObject,'String')) returns contents of Dim as a double + + +% --- Executes during object creation, after setting all properties. +function Dim_CreateFcn(hObject, eventdata, handles) +% hObject handle to Dim (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function CostFunction_Callback(hObject, eventdata, handles) +% hObject handle to CostFunction (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of CostFunction as text +% str2double(get(hObject,'String')) returns contents of CostFunction as a double + + +% --- Executes during object creation, after setting all properties. +function CostFunction_CreateFcn(hObject, eventdata, handles) +% hObject handle to CostFunction (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit7_Callback(hObject, eventdata, handles) +% hObject handle to edit7 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit7 as text +% str2double(get(hObject,'String')) returns contents of edit7 as a double + + +% --- Executes during object creation, after setting all properties. +function edit7_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit7 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +SearchAgents_no=str2num(get(handles.WolfNo,'String')); +Max_iteration=str2num(get(handles.IterNo,'String')); +lb=str2num(get(handles.LowerBound,'String')); +ub=str2num(get(handles.UpperBound,'String')); +dim=str2num(get(handles.Dim,'String')); +fobj=str2func(get(handles.CostFunction,'String')); + +cla(handles.axes2) +reset(handles.axes2) +box on +value = get(handles.checkbox1, 'Value') + +[Best_score,Best_pos,GWO_cg_curve]=GWO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj,handles,value); + +set(handles.edit9,'String', num2str(Best_pos) ); +set(handles.edit10,'String', num2str(Best_score) ); + + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + close(handles.figure1) + + +% --- Executes on button press in checkbox1. +function checkbox1_Callback(hObject, eventdata, handles) +% hObject handle to checkbox1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of checkbox1 + + + +function edit8_Callback(hObject, eventdata, handles) +% hObject handle to edit8 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit8 as text +% str2double(get(hObject,'String')) returns contents of edit8 as a double + + +% --- Executes during object creation, after setting all properties. +function edit8_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit8 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton3. +function pushbutton3_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + + +function edit9_Callback(hObject, eventdata, handles) +% hObject handle to edit9 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit9 as text +% str2double(get(hObject,'String')) returns contents of edit9 as a double + + +% --- Executes during object creation, after setting all properties. +function edit9_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit9 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit10_Callback(hObject, eventdata, handles) +% hObject handle to edit10 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit10 as text +% str2double(get(hObject,'String')) returns contents of edit10 as a double + + +% --- Executes during object creation, after setting all properties. +function edit10_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit10 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end diff --git a/GWO_toolbox.png b/GWO_toolbox.png new file mode 100644 index 0000000..5b60031 Binary files /dev/null and b/GWO_toolbox.png differ diff --git a/Readme.txt b/Readme.txt new file mode 100644 index 0000000..4d314da --- /dev/null +++ b/Readme.txt @@ -0,0 +1,21 @@ + + +All diminsions of the truss are in "ft" and appropriate conversions have been done to convert it to "m". +The final weight of the truss will come in "kN". + +Appropriate changes need to be made in the values for various other types of trusses. + +The optimization is done using Grey Wolf Optimizer toolbox +The toolbox is developed by Seyedali Mirjalili and is available on the website - https://seyedalimirjalili.com/gwo + + +Steps: + +1. Run the GWO_toolbox.m file +2. A dialog box will appear. +3. Enter the values of the lower bound, upper bound, number of variables and name of the objective function + + "Truss26ObjFnManual" will give the quickest results. + + "Truss26ObjFn" imports the relevant data from the excel file 26StoreyTruss.xlsx +4. Click on Start Optimization. diff --git a/Truss26ObjFn.m b/Truss26ObjFn.m new file mode 100644 index 0000000..bb32e69 --- /dev/null +++ b/Truss26ObjFn.m @@ -0,0 +1,228 @@ +%=========================================================================% +% This is an objective function file for optimizing the weight of 942 bar +% tower truss. +% +% The optimization is done using Grey Wolf Optimizer toolbox +% The toolbox is developed by Seyedali Mirjalili and is available on the +% website - https://seyedalimirjalili.com/gwo +% +% The lower bound (lb) is the minimum area allowed = 0.000064516 +% The upper bound (ub) is the maximum area allowed = 0.0129032 +% The number of variables = 59 +%=========================================================================% +function z=Truss26ObjFn(Q) +M=importdata(['26StoreyTruss','.xls']); % all values in excel are in ft. +nod=M.data.nodes; +n=max(nod(:,1)); % no of nodes + +elem=M.data.elements; +ne=max(elem(:,1)); % no of elements + +ndof=3; % no of DOF's +nen=2; % no of nodes for each element +nee=nen*ndof; +Nd=0.381; % Node Displacement Limit in m +Fy=172368.932; % Stress Limit in kN/m2 + + +% area of the elements in sq.m +ar(1,1:2)=Q(1); +ar(1,3:10)=Q(2); +ar(1,11:18)=Q(3); +ar(1,19:34)=Q(4); +ar(1,35:46)=Q(5); +ar(1,47:58)=Q(6); +ar(1,59:82)=Q(7); +ar(1,83:86)=Q(8); +ar(1,87:94)=Q(9); +ar(1,95:98)=Q(10); +ar(1,99:106)=Q(11); +ar(1,107:122)=Q(12); +ar(1,123:130)=Q(13); +ar(1,131:162)=Q(14); +ar(1,163:170)=Q(15); +ar(1,171:186)=Q(16); +ar(1,187:194)=Q(17); +ar(1,195:226)=Q(18); +ar(1,227:234)=Q(19); +ar(1,235:258)=Q(20); +ar(1,259:270)=Q(21); +ar(1,271:318)=Q(22); +ar(1,319:330)=Q(23); +ar(1,331:338)=Q(24); +ar(1,339:342)=Q(25); +ar(1,343:350)=Q(26); +ar(1,351:358)=Q(27); +ar(1,359:366)=Q(28); +ar(1,367:382)=Q(29); +ar(1,383:390)=Q(30); +ar(1,391:398)=Q(31); +ar(1,399:430)=Q(32); +ar(1,431:446)=Q(33); +ar(1,447:462)=Q(34); +ar(1,463:486)=Q(35); +ar(1,487:498)=Q(36); +ar(1,499:510)=Q(37); +ar(1,511:558)=Q(38); +ar(1,559:582)=Q(39); +ar(1,583:606)=Q(40); +ar(1,607:630)=Q(41); +ar(1,631:642)=Q(42); +ar(1,643:654)=Q(43); +ar(1,655:702)=Q(44); +ar(1,703:726)=Q(45); +ar(1,727:750)=Q(46); +ar(1,751:774)=Q(47); +ar(1,775:786)=Q(48); +ar(1,787:798)=Q(49); +ar(1,799:846)=Q(50); +ar(1,847:870)=Q(51); +ar(1,871:894)=Q(52); +ar(1,895:902)=Q(53); +ar(1,903:906)=Q(54); +ar(1,907:910)=Q(55); +ar(1,911:918)=Q(56); +ar(1,919:926)=Q(57); +ar(1,927:934)=Q(58); +ar(1,935:942)=Q(59); + +%Fixed Degree of Freedom +fixed_dof=M.data.boundary_conditions(697:732,3); + +% Connections +c1=elem(:,2); +c2=elem(:,3); +L1=[c1,c2]; + +L=L1'; + +% Coordinates in ft converted to m by dividing by 3.28084 +xcoord=nod(:,2); +ycoord=nod(:,3); +zcoord=nod(:,4); + +coord1=[xcoord,ycoord,zcoord]; % x, y, z coordinates of all the elements in ft + +coord=(1/3.28084)*coord1'; % converting to m. + +%Loading +load=4.448*(M.data.external_loads(:,4)); % in kN + +E=68947572.93178299; % youngs modulus kN/m2 +den=27.1447; % density of material in kN/m3 + + +%% Calculation +%getting the ID matrix from the information given +ID=zeros(ndof,n); +r=size(ID); +c=r(1,2); %no of nodes +r=r(1,1); %dof +number=1; +for c1=1:c + for r1=1:r + ID(r1,c1)=number; + number=number+1; + end +end + +fixed_dof=sort(fixed_dof); +fixed1=fixed_dof; +node=1:1:n*ndof; +free_dof=node; +for i=1:length(fixed_dof) + free_dof(fixed1(i))=[]; + fixed1=fixed1-1; %to remove fixed dof otherwise will be 2,4,6,... +end +clear fixed1; +free_dof=sort(free_dof); +free_dof=free_dof'; +for e=1:ne + for i=1:nen + for a=1:ndof + p=ndof*(i-1)+a; + LM(p,e)=ID(a,L(i,e)); + end + end +end +K=zeros(n*ndof); +lambda_vec=[]; +h_vec=[]; +%assembly +for e=1:ne %coordinates matrix of each element + localcoord=[coord(:,L(1,e)) coord(:,L(2,e))]; + h=0; + for count=1:ndof %length of member + temp=(localcoord(count,2)-localcoord(count,1))^2; + h=h+temp; + end + h=sqrt(h); + h_vec=[h_vec;h]; + lambda=[]; + for count=1:ndof %direction cosines in lambda matrix like cosx + lambda=[lambda;(localcoord(count,2)-localcoord(count,1))/h]; + %first one is lambda x ans second one is lambda y and so on + end + lambda_vec=[lambda_vec lambda]; + A=lambda*lambda'; + k=(E*ar(e))/h*[A -A;-A A]; + for p=1:nee + P=LM(p,e); + for q=1:nee + Q=LM(q,e); + K(P,Q)=K(P,Q)+k(p,q); % Global Stiffness matrix + end + end +end +lambda_vec=lambda_vec'; +K1=K; +%applying boundary conditions +for counter=1:length(fixed_dof) + K1(fixed_dof(counter),:)=[]; + K1(:,fixed_dof(counter))=[]; + fixed_dof=fixed_dof-1; +end +load1=load(1:696); +d=K1\load1; +disp_vec=zeros(n*ndof,1); +for count=1:length(free_dof) + disp_vec(free_dof(count))=d(count); +end + +%% Weight +TW=0; +for i=1:ne + W=den*ar(i)*h_vec(i); + TW=TW+W; % weight in kN +end + +%% post processing +D_big=[]; +count=1; +for i=1:n + D=[]; + for j=1:ndof + t=disp_vec(count); + count=count+1; + D=[D;t]; + end + D_big=[D_big D]; +end +axial_vec=[]; +force_vec=[]; +for i=1:ne + d1=lambda_vec(i,:)*D_big(:,L(1,i)); + d2=lambda_vec(i,:)*D_big(:,L(2,i)); + axial=(E/h_vec(i))*(d2-d1); + axial_vec=[axial_vec;axial]; + force=ar(i)*axial_vec(i); + force_vec=[force_vec;force]; +end +axial_vec; + + +z=TW+sum(max(abs(disp_vec)-Nd*ones(732,1),zeros(732,1)))+sum(max(axial_vec-(Fy*ones(942,1)),zeros(942,1))); + + +end + diff --git a/Truss26ObjFnManual.m b/Truss26ObjFnManual.m new file mode 100644 index 0000000..1e0dc6c --- /dev/null +++ b/Truss26ObjFnManual.m @@ -0,0 +1,211 @@ +%=========================================================================% +% This is an objective function file for optimizing the weight of 942 bar +% tower truss. +% +% The optimization is done using Grey Wolf Optimizer toolbox +% The toolbox is developed by Seyedali Mirjalili and is available on the +% website - https://seyedalimirjalili.com/gwo +% +% The lower bound (lb) is the minimum area allowed = 0.000064516 +% The upper bound (ub) is the maximum area allowed = 0.0129032 +% The number of variables = 59 +%=========================================================================% +function z=Truss26ObjFnManual(Q) +n=244; % no of nodes +ne=942; % no of elements +ndof=3; % no of DOF's +nen=2; % no of nodes for each element +nee=nen*ndof; +Nd=0.381; % Node Displacement Limit in m +Fy=172368.932; % Stress Limit in kN/m2 + +% area of the elements in sq.m +ar(1,1:2)=Q(1); +ar(1,3:10)=Q(2); +ar(1,11:18)=Q(3); +ar(1,19:34)=Q(4); +ar(1,35:46)=Q(5); +ar(1,47:58)=Q(6); +ar(1,59:82)=Q(7); +ar(1,83:86)=Q(8); +ar(1,87:94)=Q(9); +ar(1,95:98)=Q(10); +ar(1,99:106)=Q(11); +ar(1,107:122)=Q(12); +ar(1,123:130)=Q(13); +ar(1,131:162)=Q(14); +ar(1,163:170)=Q(15); +ar(1,171:186)=Q(16); +ar(1,187:194)=Q(17); +ar(1,195:226)=Q(18); +ar(1,227:234)=Q(19); +ar(1,235:258)=Q(20); +ar(1,259:270)=Q(21); +ar(1,271:318)=Q(22); +ar(1,319:330)=Q(23); +ar(1,331:338)=Q(24); +ar(1,339:342)=Q(25); +ar(1,343:350)=Q(26); +ar(1,351:358)=Q(27); +ar(1,359:366)=Q(28); +ar(1,367:382)=Q(29); +ar(1,383:390)=Q(30); +ar(1,391:398)=Q(31); +ar(1,399:430)=Q(32); +ar(1,431:446)=Q(33); +ar(1,447:462)=Q(34); +ar(1,463:486)=Q(35); +ar(1,487:498)=Q(36); +ar(1,499:510)=Q(37); +ar(1,511:558)=Q(38); +ar(1,559:582)=Q(39); +ar(1,583:606)=Q(40); +ar(1,607:630)=Q(41); +ar(1,631:642)=Q(42); +ar(1,643:654)=Q(43); +ar(1,655:702)=Q(44); +ar(1,703:726)=Q(45); +ar(1,727:750)=Q(46); +ar(1,751:774)=Q(47); +ar(1,775:786)=Q(48); +ar(1,787:798)=Q(49); +ar(1,799:846)=Q(50); +ar(1,847:870)=Q(51); +ar(1,871:894)=Q(52); +ar(1,895:902)=Q(53); +ar(1,903:906)=Q(54); +ar(1,907:910)=Q(55); +ar(1,911:918)=Q(56); +ar(1,919:926)=Q(57); +ar(1,927:934)=Q(58); +ar(1,935:942)=Q(59); + +fixed_dof=[697;698;699;700;701;702;703;704;705;706;707;708;709;710;711;712;713;714;715;716;717;718;719;720;721;722;723;724;725;726;727;728;729;730;731;732]; % constrained DOF's + +L=[1,2,1,3,1,2,5,7,5,6,2,1,4,3,6,5,8,7,2,1,2,4,4,3,1,3,6,5,6,8,8,7,7,5,9,11,9,10,13,15,13,14,17,19,17,18,10,9,12,11,14,13,16,17,18,17,20,19,9,10,10,12,12,11,11,9,13,14,14,16,16,15,15,13,17,18,18,20,20,19,19,17,21,23,21,22,22,21,22,24,24,23,23,21,22,21,24,23,22,21,22,24,24,23,23,21,25,26,25,28,30,31,27,29,33,34,33,36,38,39,35,37,25,27,30,32,33,35,38,40,25,26,26,27,28,25,27,29,29,32,32,31,31,30,30,28,33,34,34,35,35,37,37,40,40,39,39,38,38,36,36,33,26,28,31,29,34,36,39,37,41,42,41,43,44,46,47,45,49,50,49,51,52,54,55,53,43,41,46,48,49,51,54,56,41,42,42,43,43,45,45,48,48,47,47,46,46,44,44,41,49,50,50,51,51,53,53,56,56,55,55,54,54,52,52,49,42,44,45,47,50,52,53,55,57,58,57,59,60,61,62,63,65,66,65,67,68,69,70,71,73,74,73,75,76,77,78,79,57,59,62,64,65,67,70,72,73,75,78,80,57,58,58,59,59,61,61,64,64,63,63,62,62,60,60,57,65,66,66,67,67,69,69,72,72,71,71,70,70,68,68,65,73,74,74,75,75,77,77,80,80,79,79,78,78,76,76,73,58,60,61,63,66,68,69,71,74,76,77,79,81,82,81,83,84,85,86,87,81,83,86,88,82,82,85,85,84,84,87,87,83,81,83,88,81,86,86,88,82,82,84,84,85,85,87,87,90,92,89,93,95,96,98,99,102,104,101,105,107,108,110,111,91,89,94,97,103,101,106,109,90,93,96,99,102,105,108,111,93,92,90,91,89,90,93,94,100,99,99,98,97,96,96,95,102,103,102,101,104,105,105,106,112,111,111,110,109,108,108,107,91,92,97,98,89,95,94,100,103,104,109,110,101,107,106,112,91,92,97,98,89,95,94,100,103,104,109,110,106,112,101,107,113,114,116,117,119,120,122,123,125,126,128,129,131,132,134,135,137,138,140,141,143,144,146,147,115,121,113,118,127,133,125,130,139,145,137,142,114,117,120,123,126,129,132,135,138,141,144,147,113,114,114,115,116,117,117,118,119,120,120,121,122,123,123,124,125,126,126,127,128,129,129,130,131,132,132,133,134,135,135,136,137,138,138,139,140,141,141,142,143,144,144,145,146,147,147,148,115,116,121,122,113,119,118,124,127,128,133,134,125,131,130,136,139,140,145,146,137,143,142,148,115,116,121,122,113,119,118,124,127,128,133,134,125,131,130,136,139,140,145,146,137,143,142,148,149,150,152,153,155,156,158,159,161,162,164,165,167,168,170,171,173,174,176,177,179,180,182,183,151,157,149,154,163,169,161,166,175,181,173,178,150,153,156,159,162,165,168,171,174,177,180,183,149,150,150,151,152,153,153,154,155,156,156,157,158,159,159,160,161,162,162,163,164,165,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,177,177,178,179,180,180,181,182,183,183,184,151,152,157,158,149,155,154,160,163,164,169,170,161,167,166,172,175,176,181,182,173,179,178,184,151,152,157,158,149,155,154,160,163,164,169,170,161,167,166,172,175,176,181,181,173,179,178,184,185,186,188,189,191,192,194,195,197,198,200,201,203,204,206,207,209,210,212,213,215,216,218,219,187,193,185,190,199,205,197,202,211,217,209,214,186,189,192,195,198,201,204,207,210,213,216,219,185,186,186,187,188,189,189,190,191,192,192,193,194,195,195,196,197,198,198,199,200,201,201,202,203,204,204,205,206,207,207,208,209,210,210,211,212,213,213,214,215,216,216,217,218,219,219,220,187,188,193,194,185,191,190,196,199,200,205,206,197,203,202,208,211,212,217,218,209,215,214,220,187,188,193,194,185,191,190,196,199,200,205,206,197,203,202,208,211,212,217,218,209,215,214,220,221,222,224,225,227,228,230,231,223,229,221,226,222,225,228,231,223,221,224,226,227,229,230,232,222,222,225,225,228,228,231,231,223,224,229,230,221,227,226,232,223,224,229,230,221,227,226,232;4,3,2,4,3,4,6,8,7,8,6,5,8,7,10,9,12,11,5,6,8,6,7,8,7,5,9,10,12,10,11,12,9,11,10,12,11,12,14,16,15,16,18,20,19,20,14,13,16,15,18,17,20,19,22,21,24,23,14,13,16,14,15,16,13,15,18,17,20,18,19,20,17,19,22,21,24,22,23,24,21,23,22,24,23,24,25,27,32,27,30,32,25,30,27,25,32,30,26,26,29,29,31,31,28,28,26,27,28,30,31,32,29,32,34,35,36,38,39,40,37,40,33,35,38,40,41,43,46,48,34,33,35,34,33,36,37,35,40,37,39,40,38,39,36,38,42,41,43,42,45,43,48,45,47,48,46,47,44,46,41,44,34,36,39,37,42,44,47,45,42,43,44,45,46,47,48,48,50,51,52,53,54,55,56,56,51,49,54,56,57,59,62,64,50,49,51,50,53,51,56,53,55,56,54,55,52,54,49,52,58,57,59,58,61,59,64,61,63,64,62,63,60,62,57,60,50,52,53,55,58,60,61,63,58,59,60,61,62,64,63,64,66,67,68,69,70,72,71,72,74,75,76,77,78,80,79,80,65,67,70,72,73,75,78,80,81,83,86,88,66,65,67,66,69,67,72,69,71,72,70,71,68,70,65,68,74,73,75,74,77,75,80,77,79,80,78,79,76,78,73,76,82,81,83,82,85,83,88,85,87,88,86,87,84,86,81,84,66,68,69,71,74,76,77,79,82,84,85,87,82,83,84,85,86,88,87,88,90,93,96,99,90,93,93,99,96,90,96,99,92,91,94,100,89,95,97,98,92,91,89,95,94,100,97,98,91,93,90,94,96,97,99,100,103,105,102,106,108,109,111,112,92,95,100,98,104,107,112,110,102,105,108,111,114,117,120,123,104,105,103,102,102,101,106,105,111,112,110,111,108,109,107,108,115,114,113,114,117,116,118,117,123,124,122,123,120,121,119,120,103,104,109,110,101,107,106,112,115,116,121,122,113,119,118,124,104,103,110,109,107,101,112,106,116,115,122,121,124,118,119,113,114,115,117,118,120,121,123,124,126,127,129,130,132,133,135,136,138,139,141,142,144,145,147,148,116,122,119,124,128,134,131,136,140,146,143,148,126,129,132,135,138,141,144,147,150,153,156,159,126,125,127,126,129,128,130,129,132,131,133,132,135,134,136,135,138,137,139,138,141,140,142,141,144,143,145,144,147,146,148,147,150,149,151,150,153,152,154,153,156,155,157,156,159,158,160,159,127,128,133,134,125,131,130,136,139,140,145,146,137,143,142,148,151,152,157,158,149,155,154,160,128,127,134,133,131,125,136,130,140,139,146,145,143,137,148,142,152,151,158,157,155,149,154,154,150,151,153,154,156,157,159,160,162,163,165,166,168,169,171,172,174,175,177,178,180,181,183,184,152,158,155,160,164,170,167,172,176,182,179,184,162,165,168,171,174,177,180,183,186,189,192,195,162,161,163,162,165,164,166,165,168,167,169,168,171,170,172,171,174,173,175,174,177,176,178,177,180,179,181,180,183,182,184,183,186,185,187,186,189,188,190,189,192,191,193,192,195,194,196,195,163,164,169,170,161,167,166,172,175,176,181,182,173,179,178,184,187,188,193,194,185,191,190,196,164,163,170,169,167,161,172,166,176,175,182,181,179,173,184,178,188,187,194,193,191,185,196,190,186,187,189,190,192,193,195,196,198,199,201,202,204,205,207,208,210,211,213,214,216,217,219,220,188,194,191,196,200,206,203,208,212,218,215,220,198,201,204,207,210,213,216,219,222,225,228,231,198,197,199,198,201,200,202,201,204,203,205,204,207,206,208,207,210,209,211,210,213,212,214,213,216,215,217,216,219,218,220,219,222,221,223,222,225,224,226,225,228,227,229,228,231,230,232,231,199,200,205,206,197,203,202,208,211,212,217,218,209,215,214,220,223,224,229,230,221,227,226,232,200,199,206,205,203,197,208,202,212,211,218,217,215,209,220,214,224,223,230,229,221,227,226,232,222,223,225,226,228,229,231,232,224,230,227,232,234,237,240,243,234,234,237,237,240,240,243,243,235,233,236,238,239,241,242,244,235,236,241,242,233,239,238,244,236,235,242,241,239,233,244,238]; % element connecting matrix + +coord=(1/3.28084)*[24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,24.5000000000000,38.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,21.6005000000000,31.5000000000000,41.3995000000000,17.5000000000000,45.5000000000000,21.6005000000000,31.5000000000000,41.3995000000000,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,0,3.50000000000000,24.5000000000000,38.5000000000000,59.5000000000000,63,0,3.50000000000000,24.5000000000000,38.5000000000000,59.5000000000000,63;24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,24.5000000000000,24.5000000000000,38.5000000000000,38.5000000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,21.6005000000000,17.5000000000000,21.6005000000000,31.5000000000000,31.5000000000000,41.3995000000000,45.5000000000000,41.3995000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,11.1199000000000,7,7,11.1199000000000,24.5000000000000,38.5000000000000,51.8801000000000,56,56,51.8801000000000,38.5000000000000,24.5000000000000,3.50000000000000,0,0,3.50000000000000,24.5000000000000,38.5000000000000,59.5000000000000,63,63,59.5000000000000,38.5000000000000;312,312,312,312,300,300,300,300,288,288,288,288,276,276,276,276,264,264,264,264,252,252,252,252,240,240,240,240,240,240,240,240,228,228,228,228,228,228,228,228,216,216,216,216,216,216,216,216,204,204,204,204,204,204,204,204,192,192,192,192,192,192,192,192,180,180,180,180,180,180,180,180,168,168,168,168,168,168,168,168,156,156,156,156,156,156,156,156,144,144,144,144,144,144,144,144,144,144,144,144,132,132,132,132,132,132,132,132,132,132,132,132,120,120,120,120,120,120,120,120,120,120,120,120,108,108,108,108,108,108,108,108,108,108,108,108,96,96,96,96,96,96,96,96,96,96,96,96,84,84,84,84,84,84,84,84,84,84,84,84,72,72,72,72,72,72,72,72,72,72,72,72,60,60,60,60,60,60,60,60,60,60,60,60,48,48,48,48,48,48,48,48,48,48,48,48,36,36,36,36,36,36,36,36,36,36,36,36,24,24,24,24,24,24,24,24,24,24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,0,0,0,0,0,0,0,0,0,0,0,0]; % coordinate vector for the 244 nodes in ft (x,y(ht),z) +% coord in m + +load=4.448*[1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;-1;-1;-3;1.50000000000000;-1;-3;-1;1;-3;1.50000000000000;-1;-3;0;-1;-3;-1;-1;-3;1.50000000000000;0;-3;-1;0;-3;1.50000000000000;1;-3;0;1;-3;-1;1;-3;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;0;-1;-6;-1;-1;-6;1.50000000000000;0;-6;-1;0;-6;1.50000000000000;1;-6;0;1;-6;-1;1;-6;1.50000000000000;-1;-6;1.50000000000000;-1;-6;1.50000000000000;-1;-6;-1;-1;-6;-1;-1;-6;-1;-1;-6;1.50000000000000;1;-6;1.50000000000000;1;-6;1.50000000000000;1;-6;-1;1;-6;-1;1;-6;-1;1;-6;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;1.50000000000000;-1;-9;-1;-1;-9;-1;-1;-9;-1;-1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;1.50000000000000;1;-9;-1;1;-9;-1;1;-9;-1;1;-9]; % load vector +% load in kN + +E=68947572.93178299; % youngs modulus kN/m2 + +den=27.1447; % density of material in kN/m3 + + +%% Calculation +%getting the ID matrix from the information given +ID=zeros(ndof,n); +r=size(ID); +c=r(1,2); %no of nodes +r=r(1,1); %dof +number=1; +for c1=1:c + for r1=1:r + ID(r1,c1)=number; + number=number+1; + end +end + +fixed_dof=sort(fixed_dof); +fixed1=fixed_dof; +node=1:1:n*ndof; +free_dof=node; +for i=1:length(fixed_dof) + free_dof(fixed1(i))=[]; + fixed1=fixed1-1; %to remove fixed dof otherwise will be 2,4,6,... +end +clear fixed1; +free_dof=sort(free_dof); +free_dof=free_dof'; +for e=1:ne + for i=1:nen + for a=1:ndof + p=ndof*(i-1)+a; + LM(p,e)=ID(a,L(i,e)); + end + end +end +K=zeros(n*ndof); +lambda_vec=[]; +h_vec=[]; +%assembly +for e=1:ne %coordinates matrix of each element + localcoord=[coord(:,L(1,e)) coord(:,L(2,e))]; + h=0; + for count=1:ndof %length of member + temp=(localcoord(count,2)-localcoord(count,1))^2; + h=h+temp; + end + h=sqrt(h); + h_vec=[h_vec;h]; + lambda=[]; + for count=1:ndof %direction cosines in lambda matrix like cosx + lambda=[lambda;(localcoord(count,2)-localcoord(count,1))/h]; + %first one is lambda x ans second one is lambda y and so on + end + lambda_vec=[lambda_vec lambda]; + A=lambda*lambda'; + k=(E*ar(e))/h*[A -A;-A A]; + for p=1:nee + P=LM(p,e); + for q=1:nee + Q=LM(q,e); + K(P,Q)=K(P,Q)+k(p,q); % Global Stiffness matrix + end + end +end +lambda_vec=lambda_vec'; +K1=K; +%applying boundary conditions +for counter=1:length(fixed_dof) + K1(fixed_dof(counter),:)=[]; + K1(:,fixed_dof(counter))=[]; + fixed_dof=fixed_dof-1; +end +load1=load(1:696); +d=K1\load1; +disp_vec=zeros(n*ndof,1); +for count=1:length(free_dof) + disp_vec(free_dof(count))=d(count); +end + +%% Weight +TW=0; +for i=1:ne + W=den*ar(i)*h_vec(i); + TW=TW+W; % weight in kN +end + +%% post processing +D_big=[]; +count=1; +for i=1:n + D=[]; + for j=1:ndof + t=disp_vec(count); + count=count+1; + D=[D;t]; + end + D_big=[D_big D]; +end +axial_vec=[]; +force_vec=[]; +for i=1:ne + d1=lambda_vec(i,:)*D_big(:,L(1,i)); + d2=lambda_vec(i,:)*D_big(:,L(2,i)); + axial=(E/h_vec(i))*(d2-d1); + axial_vec=[axial_vec;axial]; + force=ar(i)*axial_vec(i); + force_vec=[force_vec;force]; +end +axial_vec; + + +z=TW+sum(max(abs(disp_vec)-Nd*ones(732,1),zeros(732,1)))+sum(max(axial_vec-(Fy*ones(942,1)),zeros(942,1))); + + +end + diff --git a/initialization.m b/initialization.m new file mode 100644 index 0000000..9dfd155 --- /dev/null +++ b/initialization.m @@ -0,0 +1,36 @@ +% Grey Wold Optimizer (GWO) source codes version 1.1 % +% % +% Developed in MATLAB R2011b(7.13) % +% % +% Author and programmer: Seyedali Mirjalili % +% % +% e-Mail: ali.mirjalili@gmail.com % +% seyedali.mirjalili@griffithuni.edu.au % +% % +% Homepage: http://www.alimirjalili.com/GWO.html % +% % +% Main paper: S. Mirjalili, S. M. Mirjalili, A. Lewis % +% Grey Wolf Optimizer, Advances in Engineering % +% Software, Volume 69, March 2014, Pages 46-61, % +% http://dx.doi.org/10.1016/j.advengsoft.2013.12.007 % +% % + +% This function initialize the first population of search agents +function Positions=initialization(SearchAgents_no,dim,ub,lb) + +Boundary_no= size(ub,2); % numnber of boundaries + +% If the boundaries of all variables are equal and user enter a signle +% number for both ub and lb +if Boundary_no==1 + Positions=rand(SearchAgents_no,dim).*(ub-lb)+lb; +end + +% If each variable has a different lb and ub +if Boundary_no>1 + for i=1:dim + ub_i=ub(i); + lb_i=lb(i); + Positions(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i; + end +end \ No newline at end of file