From: Omega Zeng on
I am new to the matlab and hope someone can take a look at this simple question. I appreciate.

The objective function is :

function [sumBarrelP0] = DoSimDriver (x)
global Nrows NB BarrelP0 MaxRideDownGs OIV y

clc;
format short e

Nrows=10;

sumBarrelP0 = sum(BarrelP0);

for i = 1:Nrows
NB(i) = x(1,i);
BarrelP0(i) = x(1,i+10);
end

y = [MaxRideDownGs; OIV];

[MaxRideDownGs,OIV]=DoSimulation(Nrows,NB,BarrelP0);

end

and constraint is:

function [c, ceq] = simple_constraint(x)
global OIV MaxRideDownGs Nrows NB BarrelP0 y

for i = 1:Nrows
NB(i) = x(1,i);
BarrelP0(i) = x(1,i+10);
end
[MaxRideDownGs,OIV]=DoSimulation(Nrows,NB,BarrelP0);

c = [MaxRideDownGs - 200;...
-OIV-1000];
ceq = [];

I am not sure if this is the right way to link the objective function with the constraints in GA. Also i am not sure about the usage of the global variables here.
Thanks.

Hao