Skip to content
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

Open
fkarimi67 opened this issue Apr 11, 2019 · 3 comments
Open

gwo #59

fkarimi67 opened this issue Apr 11, 2019 · 3 comments
Labels

Comments

@fkarimi67
Copy link

hello where is the main of gwo file?

@DiegoCatalano
Copy link
Owner

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 !!!

@fkarimi67
Copy link
Author

fkarimi67 commented Apr 12, 2019 via email

@fkarimi67
Copy link
Author

fkarimi67 commented Apr 13, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants