Open fkarimi67 opened 5 years ago
Hello @fkarimi67,
Rastrigin function.
public class Rastrigin implements ISingleObjectiveFunction{
public Rastrigin() {}
@Override
public double Compute(double[] values) {
double sum = 0;
for (int i = 0; i < values.length; i++) {
sum += values[i]*values[i] - 10 * Math.cos(2*Math.PI*values[i]);
}
return 10 * values.length + sum;
}
}
Now the main code below:
ISingleObjectiveFunction fun = new Rastrigin();
List<DoubleRange> boundConstraints = new ArrayList<>();
for (int i = 0; i < 30; i++) {
boundConstraints.add(new DoubleRange(-5.12, 5.12));
}
IOptimization opt = new GreyWolfOptimizer(25, 1000);
double[] bestSolution = opt.Compute(fun, boundConstraints);
double error = opt.getError();
System.out.println(error);
Cheers !!!
Thank you
In which part of the program I add code? Error no main classes found?
On Fri, 12 Apr 2019 02:36 Marcos Diego Catalano <notifications@github.com wrote:
Hello @fkarimi67 https://github.com/fkarimi67,
Rastrigin function.
public class Rastrigin implements ISingleObjectiveFunction{
public Rastrigin() {} @Override public double Compute(double[] values) { double sum = 0; for (int i = 0; i < values.length; i++) { sum += values[i]*values[i] - 10 * Math.cos(2*Math.PI*values[i]); } return 10 * values.length + sum; }
}
Now the main code below:
ISingleObjectiveFunction fun = new Rastrigin(); List
boundConstraints = new ArrayList<>();for (int i = 0; i < 30; i++) { boundConstraints.add(new DoubleRange(-5.12, 5.12)); } IOptimization opt = new GreyWolfOptimizer(25, 1000); double[] bestSolution = opt.Compute(fun, boundConstraints);double error = opt.getError(); System.out.println(error); Cheers !!!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiegoCatalano/Catalano-Framework/issues/59#issuecomment-482340664, or mute the thread https://github.com/notifications/unsubscribe-auth/AshRg4xC3qRndhjQh3kUJLYS_xDtaJETks5vf7HQgaJpZM4cqraM .
Hi, is this code correct?
hello where is the main of gwo file?