Skip to content
Snippets Groups Projects
Commit 3f54c528 authored by Bernhard Johannes Berger's avatar Bernhard Johannes Berger
Browse files

Added a EvoalComponent interface and added the possibility to implement custom selectors.

parent ed338a7f
No related branches found
No related tags found
No related merge requests found
Pipeline #260108 passed
package de.evoal.core.ea.main.selector;
import de.evoal.core.api.cdi.EvoalComponent;
import io.jenetics.Selector;
public interface SelectorComponent extends EvoalComponent<SelectorComponent>, Selector {
}
package de.evoal.core.ea.main.producer;
package de.evoal.core.ea.main.selector;
import de.evoal.core.api.board.CoreBlackboardEntries;
import de.evoal.core.api.cdi.BeanFactory;
import de.evoal.core.api.cdi.ConfigurationValue;
import de.evoal.core.api.utils.LanguageHelper;
import de.evoal.core.ea.main.comparator.ParetoOptimisationValue;
......@@ -55,17 +56,8 @@ public class SelectorFactory {
case "linear-rank-selector": return createLinearRankSelector(config);
case "roulette-wheel-selector": return createRouletteWheelSelector(config);
}
log.error("Configured selector with name '{}' is not supported. Available selectors are:\n" +
" elite-selector,\n" +
" monte-carlo-selector,\n" +
" stochastic-universal-selector,\n" +
" tournament-selector,\n" +
" truncation-selector,\n" +
" boltzmann-selector,\n" +
" exponential-rank-selector,\n" +
" linear-rank-selector,\n" +
" roulette-wheel-selector", name);
throw new IllegalStateException("Selector '" + name + "' is unknown.");
return BeanFactory.create(name, SelectorComponent.class).init(config);
}
private <G extends Gene<?, G>, C extends Comparable<? super C>> Selector<G, C> createNSGA2Selector(final Instance config) {
......
......@@ -33,7 +33,7 @@ module de.evoal.core.ea {
opens de.evoal.core.ea.main.constraint to weld.core.impl;
opens de.evoal.core.ea.main.fitness to weld.core.impl;
opens de.evoal.core.ea.main.initial to weld.core.impl;
opens de.evoal.core.ea.main.producer to weld.core.impl;
opens de.evoal.core.ea.main.selector to weld.core.impl;
opens de.evoal.core.ea.main.search to weld.core.impl;
opens de.evoal.core.ea.main.statistics to weld.core.impl;
}
package de.evoal.core.api.cdi;
import de.evoal.languages.model.base.Instance;
/**
* Base class for components that allow initialisation using an init method.
*/
public interface EvoalComponent<T extends EvoalComponent<T>> {
/**
* Initialises the component based on the given configuration.
*
* @param configuration The configuration to use.
*
* @return The component itself.
*/
public T init(final Instance configuration);
}
package de.evoal.core.api.optimisation;
import de.evoal.core.api.cdi.EvoalComponent;
import de.evoal.languages.model.base.Instance;
/**
* Interface for all optimisation algorithms.
*/
public interface OptimisationAlgorithm {
/**
* Initialises the algorithm based on the given configuration.
*
* @param instance The configuration to use.
*
* @return The algorithm itself.
*/
OptimisationAlgorithm init(final Instance instance);
public interface OptimisationAlgorithm extends EvoalComponent<OptimisationAlgorithm> {
/**
* Does the actual optimisation.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment