Skip to content

Instantly share code, notes, and snippets.

View dhadka's full-sized avatar

David Hadka dhadka

  • Microsoft, GitHub
  • Fort Collins, CO
View GitHub Profile
@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;
@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 / 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 / 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 / ExampleSinglePointBinaryCrossover.java
Created July 27, 2016 12:50
Demonstrates creating a new operator within the MOEA Framework
/* 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 / RuntimeApproximationSets.java
Created July 27, 2016 12:22
RuntimeApproximationSets.java
Instrumenter instrumenter = new Instrumenter()
.withProblem("UF1")
.withFrequency(100)
.attachApproximationSetCollector();
new Executor()
.withProblem("UF1")
.withAlgorithm("NSGAII")
.withMaxEvaluations(10000)
.withInstrumenter(instrumenter)
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
// FPGAFitnessComparator.java
//
// Author:
// Antonio J. Nebro <antonio@lcc.uma.es>
// Juan J. Durillo <durillo@lcc.uma.es>
//
// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
@dhadka
dhadka / Rhodium.ipynb
Last active September 27, 2019 05:34
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dhadka
dhadka / NSGAIII-Example.java
Last active December 20, 2015 15:38
Creating an instance of NSGA-III
private Algorithm newNSGAIII(TypedProperties properties, Problem problem) {
int divisionsOuter = 4;
int divisionsInner = 0;
if (properties.contains("divisionsOuter") && properties.contains("divisionsInner")) {
divisionsOuter = (int)properties.getDouble("divisionsOuter", 4);
divisionsInner = (int)properties.getDouble("divisionsInner", 0);
} else if (properties.contains("divisions")){
divisionsOuter = (int)properties.getDouble("divisions", 4);
} else if (problem.getNumberOfObjectives() == 1) {