MCPcopy Create free account
hub / github.com/LangZhong36/immortal-jellyfish-algorithm / main

Method main

java/src/main/java/ija/Main.java:33–65  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

31 };
32
33 public static void main(String[] args) {
34 int dim = 30;
35 int n = 50;
36 int maxIter = 500;
37
38 System.out.printf("%-14s %16s %12s %10s%n",
39 "Function", "Best Fitness", "NFev", "Time (ms)");
40 System.out.println("-".repeat(58));
41
42 for (int fid = 0; fid < BenchmarkFunctions.NAMES.length; fid++) {
43 final int id = fid;
44 final double lb = BOUNDS[fid][0];
45 final double ub = BOUNDS[fid][1];
46
47 Function<double[], Double> objective = x -> BenchmarkFunctions.evaluate(id, x);
48
49 IJA solver = new IJA.Builder()
50 .n(n)
51 .maxIter(maxIter)
52 .seed(42L)
53 .build();
54
55 long t0 = System.currentTimeMillis();
56 OptimizeResult result = solver.optimize(objective, dim, lb, ub);
57 long elapsed = System.currentTimeMillis() - t0;
58
59 System.out.printf("%-14s %16.6e %12d %10d%n",
60 BenchmarkFunctions.NAMES[fid],
61 result.bestFitness,
62 result.nFunctionEvals,
63 elapsed);
64 }
65 }
66}

Callers

nothing calls this directly

Calls 6

evaluateMethod · 0.95
optimizeMethod · 0.95
buildMethod · 0.80
seedMethod · 0.80
maxIterMethod · 0.80
nMethod · 0.80

Tested by

no test coverage detected