-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gwo #59
Labels
Comments
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 ***@***.*** 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<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 !!!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#59 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AshRg4xC3qRndhjQh3kUJLYS_xDtaJETks5vf7HQgaJpZM4cqraM>
.
|
Hi, is this code correct?
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello where is the main of gwo file?
The text was updated successfully, but these errors were encountered: