Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: GA optimization

Subject: GA optimization

From: OK1

Date: 15 May, 2008 10:29:02

Message: 1 of 5

Hi all,

I have solved the given problem described below by GA but
my results are real numbers. How can I get results in
discrete values? They should be whitin the range:

Ri=(60:1:90);
Ro=(80:1:110);
A=(1:0.5:3);
F=(600:10:1000);
Z=(2:1:10);

Is it possible to get results in discrete values when using
gamultiobjective in GA toolbox at all? If yes could you
please explain it to me how to do it and what should I do.
I'm just matlab user and I'm not good in programming at all
some detailed description as for dumbbell :-) would be
great.

Thank You

Problem:
five design variables: x=[Ri;Ro;A;F;Z]

objective functions:

f(1)= pi*(Ro^2-Ri^2)*A*(Z+1)*Rho; % min weight
f(2)=Jz*omega/(Mh+Mf)*1000; % min time

subject to:

linear constraints:
  Aineq=[-1 0 0 0 0;0 1 0 0 0;1 -1 0 0 0;0 0 -1 0 0;...
0 0 1 0 0;0 0 0 0 1;0 0 0 0 -1;0 0 0 -1 0;0 0 0 1 0];
bineq=[-55;110;-20;-1.5;3;9;-1;0;1000];

nonlinear constraints:
where c=<0
c=[-Lmax+(Z+1)*(A+delta);prz-pmax;s*Ms-Mh;...
-th;prz*Vsr-pmax*Vsrmax;Vsr-Vsrmax];
                                                 
ceq=[];

where:

Rimin=55;
Romax=110;
deltaR=20;
Amin=1.5;
Amax=3;
delta=0.5;
Lmax=30;
Zmax=10;
Vsrmax=10000;
mi=0.5;
Rho=0.000007850;
s=1.5;
Ms=40000;
Mf=3000;
n=250;
pmax=1;
Jz=55;
Fmax=1000;

and

S=pi*(Ro^2-Ri^2);
prz=F/S ;
Rsr=(2/3)*((Ro^3-Ri^3)/(Ro^2-Ri^2));
Vsr=(pi*Rsr*n)/30;
omega=(pi*n)/30;
Mh=2/3*mi*F*Z*((Ro^3-Ri^3)/(Ro^2-Ri^2));

Subject: Re: GA optimization

From: matt dash

Date: 15 May, 2008 16:40:19

Message: 2 of 5

I could be wrong, but if you just rewrote your objective
function to round each variable, wouldn't it find the
optimum integer solution? (It would still return non integer
results but rounding them would give the same solution).

Subject: Re: GA optimization

From: helper

Date: 15 May, 2008 18:23:02

Message: 3 of 5

> I have solved the given problem described below by GA but
> my results are real numbers. How can I get results in
> discrete values?

This is called "Integer Programming". Check out the
following link:

http://www.mathworks.com/support/solutions/data/1-
10PDHC.html?solution=1-10PDHC



Subject: Re: GA optimization

From: Marcus M. Edvall

Date: 19 May, 2008 03:44:39

Message: 4 of 5

Hello - you can solve this problem with glcDirect, minlpBB and more in
TOMLAB.

The demo is available from here: http://tomopt.com/tomlab/

Best wishes, Marcus

Subject: Re: GA optimization

From: Marcus M. Edvall

Date: 19 May, 2008 04:06:26

Message: 5 of 5

Here is some quick TOMLAB code. It doesn't look like your formulation
is complete since th is missing:

Anyway, it might be a starting point for you. In general I would
recommend that you code the gradient and use MAD for the 2nd order
derivatives:

function Result = newsok

% Ri=(60:1:90);
% Ro=(80:1:110);
% A=(1:0.5:3);
% F=(600:10:1000);
% Z=(2:1:10);
% x=[Ri;Ro;A;F;Z]
% Need 2 here and divide by 2 in funcs
x_L = [60;80;2;600;2];
x_U = [90;110;6;1000;10];

x_0 = round((x_L+x_U)/2);

c_U = zeros(5,1);

Aineq=[-1 0 0 0 0;0 1 0 0 0;1 -1 0 0 0;0 0 -1 0 0;...
    0 0 1 0 0;0 0 0 0 1;0 0 0 0 -1;0 0 0 -1 0;0 0 0 1 0];
bineq=[-55;110;-20;-1.5;3;9;-1;0;1000];
% x(3) is not twice as high, need to divide column by 2
Aineq(:,3) = Aineq(:,3)/2;
Prob = minlpAssign(@objfun, [], [], [], x_L, x_U, 'NewsOK', x_0, ...
    1:5, [], [], [], Aineq, -inf*ones(length(bineq),1), bineq, ...
    @consfun, [], [], [], [], c_U);
Prob.user.Rho=0.000007850;
Prob.PriLevOpt = 4;
Prob.optParam.IterPrint = 1;
Result = tomRun('minlpBB', Prob, 1);
Result.x_k(3) = Result.x_k(3)/2;

function f = objfun(x,Prob)
x(3) = x(3)/2;
Ri = x(1);
Ro = x(2);
A = x(3);
Z = x(5);
Rho = Prob.user.Rho;
f(1)= pi*(Ro^2-Ri^2)*A*(Z+1)*Rho; % min weight

%f(2)=Jz*omega/(Mh+Mf)*1000; % min time

function c = consfun(x,Prob)
x(3) = x(3)/2;
Ri = x(1);
Ro = x(2);
A = x(3);
F = x(4);
Z = x(5);

% Rimin=55;
% Romax=110;
% deltaR=20;
% Amin=1.5;
% Amax=3;
delta=0.5;
Lmax=30;
% Zmax=10;
Vsrmax=10000;
mi=0.5;
s=1.5;
Ms=40000;
% Mf=3000;
n=250;
pmax=1;
% Jz=55;
% Fmax=1000;
S=pi*(Ro^2-Ri^2);
prz=F/S ;
Rsr=(2/3)*((Ro^3-Ri^3)/(Ro^2-Ri^2));
Vsr=(pi*Rsr*n)/30;
% omega=(pi*n)/30;
Mh=2/3*mi*F*Z*((Ro^3-Ri^3)/(Ro^2-Ri^2));

c=[-Lmax+(Z+1)*(A+delta);prz-pmax;s*Ms-Mh;...
prz*Vsr-pmax*Vsrmax;Vsr-Vsrmax];
% -th; removed since not defined

Best wishes, Marcus
Tomlab Optimization Inc.
http://tomopt.com/tomlab/

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
integer programming helper 15 May, 2008 14:25:07
ga helper 15 May, 2008 14:25:07
results OK1 15 May, 2008 06:30:26
ga optimization OK1 15 May, 2008 06:30:26
discrete values OK1 15 May, 2008 06:30:25
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics