%Author: Ashish Khetan (khetan2@illinois.edu)
%Engineering System Design Lab,
%Industrial and Enterprise Systems Engineering, UIUC, IL, USA
% Copyright (c) 2013, Engineering System Design Lab (ESDL)
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
%
% Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
% Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
% Neither the name of the ESDL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
%AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
%(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
%STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
% Function to calculate stress constraints violations for a given topology
% when optimized for its inner loop(optimal size)
function [violation p] = GAcon(x)
[Coord Con]= Generate_Genome(x);
D=TrussData(Coord, Con);
sigmamax = 25e3;
sw = 0.1;
A0 = ones([1,size(D.Con,2)]);
lb = zeros(size(A0,2),1); lb(:) = 0.1;
ag = zeros(1, size(A0,2));
iteration = 0; epsilon = 0.01; error = 1;
%////////////Sequential Linear Programming/////////////////
while abs(error)>epsilon
iteration = iteration +1;
stress = Stresscal(D, A0);
sign = eye(size(stress,1));
for i = 1:size(stress)
if (stress(i) > 0)
ag(1,i) = stress(i) - sigmamax;
sign(i,i) = 1;
else
ag(1,i) = -stress(i) - sigmamax;
sign(i,i) = -1;
end
end
stressconstraint = ag(:);
JacobianStress = JacobianStresscal(D, A0);
JacobianStress = sign*JacobianStress;
coefflinconstraint = JacobianStress;
coeffconstant = -(stressconstraint + JacobianStress*(-A0(:)));
options = optimset('Display', 'off');
A1 = linprog(D.Length(:),coefflinconstraint,coeffconstant,[],[],lb,[],[],options);
error = norm(A1-A0(:));
if(size(A1,1)~= size(A0,2))
display('Trouble');
end
A0(:) = A1;
if (iteration > 100)
break;
end
end
stress = Stresscal(D, A0);
% Database 'ag' saves stress violations
for i = 1:size(stress)
if (stress(i) > 0)
ag(1,i) = stress(i) - sigmamax;
else
ag(1,i) = -stress(i) - sigmamax;
end
end
p = 0;
violation = 0;
for i = 1:size(ag,2)
if(ag(i)>1e-5)
violation = violation +100; % For every violation a penalty of 100 units is added.
end
end
end