Reformat code and optimize imports.
Language Level changed to 1.7
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
package eva2.cli;
|
||||
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.optimization.strategies.DifferentialEvolution;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.util.annotation.Parameter;
|
||||
import org.apache.commons.cli.*;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Main implements OptimizationStateListener {
|
||||
|
||||
|
||||
|
||||
private static Options createDefaultCommandLineOptions() {
|
||||
Options opt = new Options();
|
||||
|
||||
@@ -56,15 +54,15 @@ public class Main implements OptimizationStateListener {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public static void printProgressBar(int percent){
|
||||
public static void printProgressBar(int percent) {
|
||||
StringBuilder bar = new StringBuilder("[");
|
||||
|
||||
for(int i = 0; i < 50; i++){
|
||||
if( i < (percent/2)){
|
||||
for (int i = 0; i < 50; i++) {
|
||||
if (i < (percent / 2)) {
|
||||
bar.append("=");
|
||||
}else if( i == (percent/2)){
|
||||
} else if (i == (percent / 2)) {
|
||||
bar.append(">");
|
||||
}else{
|
||||
} else {
|
||||
bar.append(" ");
|
||||
}
|
||||
}
|
||||
@@ -78,9 +76,9 @@ public class Main implements OptimizationStateListener {
|
||||
|
||||
Reflections reflections = new Reflections("eva2.optimization.strategies");
|
||||
Set<Class<? extends InterfaceOptimizer>> optimizers = reflections.getSubTypesOf(InterfaceOptimizer.class);
|
||||
for(Class<? extends InterfaceOptimizer> optimizer : optimizers) {
|
||||
for (Class<? extends InterfaceOptimizer> optimizer : optimizers) {
|
||||
// We only want instantiable classes.ya
|
||||
if(optimizer.isInterface() || Modifier.isAbstract(optimizer.getModifiers())) {
|
||||
if (optimizer.isInterface() || Modifier.isAbstract(optimizer.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
optimizerList.put(optimizer.getSimpleName(), optimizer);
|
||||
@@ -92,9 +90,9 @@ public class Main implements OptimizationStateListener {
|
||||
Map<String, Class<? extends InterfaceOptimizationProblem>> problemList = new TreeMap<String, Class<? extends InterfaceOptimizationProblem>>();
|
||||
Reflections reflections = new Reflections("eva2.optimization.problems");
|
||||
Set<Class<? extends InterfaceOptimizationProblem>> problems = reflections.getSubTypesOf(InterfaceOptimizationProblem.class);
|
||||
for(Class<? extends InterfaceOptimizationProblem> problem : problems) {
|
||||
for (Class<? extends InterfaceOptimizationProblem> problem : problems) {
|
||||
// We only want instantiable classes
|
||||
if(problem.isInterface() || Modifier.isAbstract(problem.getModifiers())) {
|
||||
if (problem.isInterface() || Modifier.isAbstract(problem.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
problemList.put(problem.getSimpleName(), problem);
|
||||
@@ -130,9 +128,9 @@ public class Main implements OptimizationStateListener {
|
||||
/**
|
||||
* Process help and help sub pages.
|
||||
*/
|
||||
if(commandLine.hasOption("help")) {
|
||||
if (commandLine.hasOption("help")) {
|
||||
String helpOption = commandLine.getOptionValue("help");
|
||||
if("optimizer".equals(helpOption)) {
|
||||
if ("optimizer".equals(helpOption)) {
|
||||
showOptimizerHelp();
|
||||
} else if ("problem".equals(helpOption)) {
|
||||
showProblemHelp();
|
||||
@@ -148,16 +146,16 @@ public class Main implements OptimizationStateListener {
|
||||
Map<String, Class<? extends InterfaceOptimizer>> optimizerList = createOptimizerList();
|
||||
|
||||
System.out.println("Available Optimizers:");
|
||||
for(String name : optimizerList.keySet()) {
|
||||
for (String name : optimizerList.keySet()) {
|
||||
System.out.printf("\t%s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showProblemHelp() {
|
||||
Map<String, Class<? extends InterfaceOptimizationProblem>> problemList= createProblemList();
|
||||
Map<String, Class<? extends InterfaceOptimizationProblem>> problemList = createProblemList();
|
||||
|
||||
System.out.println("Available Problems:");
|
||||
for(String name : problemList.keySet()) {
|
||||
for (String name : problemList.keySet()) {
|
||||
System.out.printf("\t%s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user