Skip to content

Instantly share code, notes, and snippets.

View dhadka's full-sized avatar

David Hadka dhadka

  • Microsoft, GitHub
  • Colorado
View GitHub Profile
@dhadka
dhadka / PopulationCollectorExample.java
Last active July 27, 2016 13:25
Demonstrates how to use a collector to record the population at each generation
/* Copyright 2009-2016 David Hadka
*
* This file is part of the MOEA Framework.
*
* The MOEA Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* The MOEA Framework is distributed in the hope that it will be useful, but
@dhadka
dhadka / SynchronizedMersenneTwister.java
Last active February 6, 2017 13:37
Creates a synchronized (thread-safe) version of the Mersenne Twister random number generator. Each thread is assigned a different instance of the MersenneTwister.
import java.security.SecureRandom;
import java.util.Random;
import org.apache.commons.math3.random.MersenneTwister;
public class SynchronizedMersenneTwister extends Random {
private static final long serialVersionUID = -4586969514356530381L;
private static Random SEEDER;
@dhadka
dhadka / FunctionMatcher.java
Last active November 8, 2017 14:22
Demonstrates grammar encodings with the MOEA Framework
import java.io.IOException;
import java.io.StringReader;
import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleBindings;
import org.moeaframework.Executor;
@dhadka
dhadka / FitnessBasedNSGAIIExample.java
Created December 22, 2017 18:00
Fitness-based NSGA-II Example
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import org.moeaframework.Executor;
import org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm;
import org.moeaframework.analysis.plot.Plot;
import org.moeaframework.core.Algorithm;
import org.moeaframework.core.EpsilonBoxDominanceArchive;