Skip to content

Commit

Permalink
Merge 3396503 into 5a72265
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorSmirnov89 committed Jun 12, 2018
2 parents 5a72265 + 3396503 commit bfad794
Show file tree
Hide file tree
Showing 35 changed files with 2,040 additions and 131 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
bin
build

# Temporary files created when working on Linux
*~

# Eclipse files are created with `gradlew eclipse`
.classpath
.project
Expand Down
3 changes: 3 additions & 0 deletions opt4j-optimizers/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dependencies {
compile project(':opt4j-core')
compile project(':opt4j-operators')

testCompile group: 'junit', name: 'junit', version: '[4.0,)'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.opt4j.optimizers.ea;

import org.opt4j.core.config.annotations.Name;

/**
* Binds the {@link CouplerDefault} as the {@link Coupler}.
*
* @author Fedor Smirnov
*
*/
@Name("Default")
public class CouplerDefaultModule extends CouplerModule {

@Override
protected void config() {
bindCoupler(CouplerDefault.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.opt4j.optimizers.ea;

import org.opt4j.core.config.Icons;
import org.opt4j.core.config.annotations.Category;
import org.opt4j.core.config.annotations.Icon;
import org.opt4j.core.config.annotations.Parent;
import org.opt4j.core.start.Opt4JModule;

/**
* Abstract module class for the {@link Coupler}.
*
* @author Fedor Smirnov
*
*/
@Icon(Icons.SELECTOR)
@Category
@Parent(EvolutionaryAlgorithmModule.class)
public abstract class CouplerModule extends Opt4JModule {

/**
* Binds the given {@link Coupler}.
*
* @param coupler
* the {@link Coupler} to bind
*/
protected void bindCoupler(Class<? extends Coupler> coupler) {
bind(Coupler.class).to(coupler).in(SINGLETON);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.opt4j.optimizers.ea;

import org.opt4j.core.config.annotations.Name;

/**
* Binds the {@link CouplerRandom} as the {@link Coupler}.
*
* @author Fedor Smirnov
*
*/
@Name("Random")
public class CouplerRandomModule extends CouplerModule {

@Override
protected void config() {
bindCoupler(CouplerRandom.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.opt4j.optimizers.ea;

import org.opt4j.core.config.annotations.Name;

/**
* Binds the {@link CouplerUnique} as the {@link Coupler}.
*
* @author Fedor Smirnov
*
*/
@Name("Unique")
public class CouplerUniqueModule extends CouplerModule {

@Override
protected void config() {
bindCoupler(CouplerUnique.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*******************************************************************************/


package org.opt4j.optimizers.ea;

Expand Down Expand Up @@ -47,19 +46,19 @@ public class EvolutionaryAlgorithmModule extends OptimizerModule {
protected int generations = 1000;

@Constant(value = "alpha", namespace = EvolutionaryAlgorithm.class)
@Info("The size of the population.")
@Info("The size of the population α.")
@Order(1)
protected int alpha = 100;
protected int populationSize = 100;

@Constant(value = "mu", namespace = EvolutionaryAlgorithm.class)
@Info("The number of parents per generation.")
@Info("The number of parents per generation μ.")
@Order(2)
protected int mu = 25;
protected int parentsPerGeneration = 25;

@Constant(value = "lambda", namespace = EvolutionaryAlgorithm.class)
@Info("The number of offspring per generation.")
@Info("The number of offsprings per generation λ.")
@Order(3)
protected int lambda = 25;
protected int offspringsPerGeneration = 25;

@Info("Performs a crossover operation with this given rate.")
@Order(4)
Expand All @@ -86,28 +85,25 @@ public enum CrossoverRateType {
/**
* Returns the population size {@code alpha}.
*
* @see #setAlpha
* @return the population size
*/
public int getAlpha() {
return alpha;
public int getPopulationSize() {
return populationSize;
}

/**
* Sets the population size {@code alpha}.
*
* @see #getAlpha
* @param alpha
* the population size to set
*/
public void setAlpha(int alpha) {
this.alpha = alpha;
public void setPopulationSize(int alpha) {
this.populationSize = alpha;
}

/**
* Returns the number of generations.
*
* @see #setGenerations
* @return the number of generations
*/
public int getGenerations() {
Expand All @@ -128,49 +124,44 @@ public void setGenerations(int generations) {
/**
* Returns the number of children {@code lambda}.
*
* @see #setLambda
* @return the number of children
*/
public int getLambda() {
return lambda;
public int getOffspringsPerGeneration() {
return offspringsPerGeneration;
}

/**
* Sets the number of children {@code lambda}.
*
* @see #getLambda
* @param lambda
* the number of children
*/
public void setLambda(int lambda) {
this.lambda = lambda;
public void setOffspringsPerGeneration(int lambda) {
this.offspringsPerGeneration = lambda;
}

/**
* Returns the number of parents {@code mu}.
*
* @see #setMu
* @return the number of parents
*/
public int getMu() {
return mu;
public int getParentsPerGeneration() {
return parentsPerGeneration;
}

/**
* Sets the number of parents {@code mu}.
*
* @see #getMu
* @param mu
* the number of parents
*/
public void setMu(int mu) {
this.mu = mu;
public void setParentsPerGeneration(int mu) {
this.parentsPerGeneration = mu;
}

/**
* Returns the type of crossover rate that is used.
*
* @see #setCrossoverRateType
* @return the crossoverRateType
*/
public CrossoverRateType getCrossoverRateType() {
Expand All @@ -180,7 +171,6 @@ public CrossoverRateType getCrossoverRateType() {
/**
* Sets the type of crossover rate to use.
*
* @see #getCrossoverRateType
* @param crossoverRateType
* the crossoverRateType to set
*/
Expand All @@ -191,7 +181,6 @@ public void setCrossoverRateType(CrossoverRateType crossoverRateType) {
/**
* Returns the used crossover rate.
*
* @see #setCrossoverRate
* @return the crossoverRate
*/
public double getCrossoverRate() {
Expand All @@ -201,7 +190,6 @@ public double getCrossoverRate() {
/**
* Sets the crossover rate.
*
* @see #getCrossoverRate
* @param crossoverRate
* the crossoverRate to set
*/
Expand All @@ -216,9 +204,7 @@ public void setCrossoverRate(double crossoverRate) {
*/
@Override
public void config() {

bindIterativeOptimizer(EvolutionaryAlgorithm.class);

bind(CrossoverRate.class).to(ConstantCrossoverRate.class).in(SINGLETON);
}
}

0 comments on commit bfad794

Please sign in to comment.