First of all I apologize for my strong word to you. I am very sorry. Yes your coding is very useful to me. Before you write I have already taken the ConstrBoundaryas soft instead of penalize and became successful. Thank you very much.
It is very sad that you have not replied my query till yet.Again I am facing another problem with your code which I am explaining.
I am getting the fitness function from a simulink file. The simulink file will run if the variables lie within lower bound and upper bound.But with your code sometimes the variables exceed the lower bound or upper bound so that the simulink file is not able to execute and it shows error.So please help me as soon as possible. Thanks.
I have to optimize 16 parameters. Out of which the first nine parameters are in the range of zero to one but the rest seven variables are in the range of one to four (only integers).So please help me to use your codings. Is your coding is useful for mixed integer constraints?Again is it useful for 16 variables?
Anticipating a quick reply.Thanking you.
I found something in one of your comments here. On 15 May 2013
"I've also made a small change to ensure that only feasible solutions are selected as global optima when the penalty-based constraint enforcement method is used."
What does this mean? We can obtain an relatively optimal result among all iterations? Is there an example of this kind of application. Or it is just set with options.ConstrBoundary = 'penalize' ? Thanks.
And another problem about population size and generation. I assigned this kind of value to these two variables.
f.option.PopulationSize = 500000; % Same to GA.
f.options.Generations = 1000 ;
But I always obtain the result like this:
x: [1.8990 0.9206 2.0019 -0.3474 -0.0901]
output: [1x1 struct]
population: [40x5 double]
scores: [40x1 double]
data1: [50x5 double]
real_v: [1x50 double]
The population dimension is 40*5.
I called the function this way:
fitnessfcn = str2func('mytest');
options = fitnessfcn('init') ;
issue1 = options;
issue1.fitnessfcn = fitnessfcn;
issue1.nvars = 5;
issue1.options.DemoMode = 'fast' ;
[x,fval,exitflag,output,population,scores] = pso(issue1);
I fixed that problem.
But one more stupid question about the objective function. Anyway, maybe I didn't understand it correctly, for I have been using GA. In GA, it always generate the maximum value of the objective function. But, here with the PSO, how I can obtain the maximum value or a minimum value. Do I need to specify some constraints with the parameters such as Aineq bineq something? Anyone help? Thanks.
Does the toolbox work for the problems that variables are more than 2?
For example, I want to implement something like
y = a1*x1 + a2*x2 + ... + an*xn
n >= 5
In my problem, I need to find out several coefficients by optimizing the 1st equation. It means that I have 'n' variables. To do so, I need to find out 'n' coefficients as well. But I got a problem of your toolbox. I have already sent you an email with my codes. Thanks.