Skip to content

Instantly share code, notes, and snippets.

View jenetics's full-sized avatar
🙄

Franz Wilhelmstötter jenetics

🙄
View GitHub Profile
@jenetics
jenetics / Creating random seeds.md
Last active August 29, 2015 14:14
Creating random seeds

Creating random seeds

Franz Wilhelmstötter, 2015.01.25

While implementing the Jenetics library, I faced the problem of creating seed values for the Random engines I used. The usual way for doing this, is to take the current time stamp.

public static long seed() {
    return System.nanoTime();
}

Keybase proof

I hereby claim:

  • I am jenetics on github.
  • I am fwilhelm (https://keybase.io/fwilhelm) on keybase.
  • I have a public key whose fingerprint is 3C2E EC52 F948 23B8 113A 527C BE5E C76F 7C08 4F3B

To claim this, I am signing this object:

import static java.lang.Math.PI;
import static org.jenetics.engine.EvolutionResult.toBestPhenotype;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.jenetics.DoubleGene;
import org.jenetics.Genotype;
import org.jenetics.Phenotype;
class WeaselSelector<
G extends Gene<?, G>,
C extends Comparable<? super C>
>
implements Selector<G, C>
{
@Override
public Population<G, C> select(
final Population<G, C> population,
final int count,
@jenetics
jenetics / DynamicGenotype.java
Created May 9, 2016 18:09
Example for dynamic Genotype/Chromosome length
import static java.lang.Math.pow;
import static org.jenetics.internal.math.random.indexes;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import org.jenetics.internal.util.IntRef;
import static java.nio.file.Files.exists;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.lang.String.format;
import static java.lang.System.getProperty;
import static java.util.Objects.requireNonNull;
import static io.jenetics.engine.EvolutionResult.toBestPhenotype;
import static io.jenetics.jpx.Length.Unit.METER;
import java.io.IOException;
import java.io.InputStream;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.HashMap;
@jenetics
jenetics / FitnessDiversity.java
Created March 2, 2018 15:04
Managing the fitness diversity with the 'CyclicEngine' class
import static io.jenetics.engine.EvolutionResult.toBestEvolutionResult;
import static io.jenetics.engine.Limits.bySteadyFitness;
import java.util.Random;
import io.jenetics.BitGene;
import io.jenetics.Mutator;
import io.jenetics.SinglePointCrossover;
import io.jenetics.engine.Engine;
import io.jenetics.engine.EvolutionResult;
@jenetics
jenetics / Op.java
Created June 11, 2019 18:02
GP operation interface
public interface Op<T>
extends Function<T[], T>, Supplier<Op<T>>
{
public String name();
public int arity();
public T apply(T[] args);
}
@jenetics
jenetics / Variables.java
Last active June 11, 2019 18:11
Defining GP terminal operations
final ISeq<Op<Double>> terminals = ISeq.of(
Var.of("x", 0), Var.of("y", 1), Var.of("z", 2)
);