This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static final ISeq<Op<Double>> OPERATIONS = ISeq.of( | |
| MathOp.ADD, | |
| MathOp.SUB, | |
| MathOp.MUL | |
| ); | |
| static final ISeq<Op<Double>> TERMINALS = ISeq.of( | |
| Var.of("x", 0), | |
| EphemeralConst.of(() -> | |
| (double)RandomRegistry.getRandom().nextInt(10)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final Engine<ProgramGene<Double>, Double> engine = Engine | |
| .builder(Main::error, program) | |
| .minimizing() | |
| .alterers( | |
| new SingleNodeCrossover<>(), | |
| new Mutator<>()) | |
| .build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final int depth = 5; | |
| final ISeq<Op<Double>> operations = ISeq.of(...); | |
| final ISeq<Op<Double>> terminals = ISeq.of(...); | |
| final ProgramChromosome<Double> program = ProgramChromosome.of( | |
| depth, | |
| operations, | |
| terminals | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final Op<Double> rand1 = EphemeralConst.of(Math::random); | |
| final Op<Double> rand2 = EphemeralConst.of("R", Math::random); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final Op<Double> one = Const.of(1.0); | |
| final Op<Double> pi = Const.of("π", Math.PI); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final ISeq<Op<Double>> terminals = ISeq.of( | |
| Var.of("x", 0), Var.of("y", 1), Var.of("z", 2) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Op<T> | |
| extends Function<T[], T>, Supplier<Op<T>> | |
| { | |
| public String name(); | |
| public int arity(); | |
| public T apply(T[] args); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |