repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jenetics/jenetics | jenetics.tool/src/main/java/io/jenetics/tool/trial/Gnuplot.java | Gnuplot.create | public void create(final Path data, final Path output)
throws IOException
{
_parameters.put(DATA_NAME, data.toString());
_parameters.put(OUTPUT_NAME, output.toString());
final String params = _parameters.entrySet().stream()
.map(Gnuplot::toParamString)
.collect(Collectors.joining("; "));
String scrip... | java | public void create(final Path data, final Path output)
throws IOException
{
_parameters.put(DATA_NAME, data.toString());
_parameters.put(OUTPUT_NAME, output.toString());
final String params = _parameters.entrySet().stream()
.map(Gnuplot::toParamString)
.collect(Collectors.joining("; "));
String scrip... | [
"public",
"void",
"create",
"(",
"final",
"Path",
"data",
",",
"final",
"Path",
"output",
")",
"throws",
"IOException",
"{",
"_parameters",
".",
"put",
"(",
"DATA_NAME",
",",
"data",
".",
"toString",
"(",
")",
")",
";",
"_parameters",
".",
"put",
"(",
... | Generate the Gnuplot graph.
@param data the input data file
@param output the output path of the graph
@throws IOException if the Gnuplot generation fails | [
"Generate",
"the",
"Gnuplot",
"graph",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/Gnuplot.java#L86-L121 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Timer.java | Timer.of | public static Timer of(final Clock clock) {
requireNonNull(clock);
return clock instanceof NanoClock
? new Timer(System::nanoTime)
: new Timer(() -> nanos(clock));
} | java | public static Timer of(final Clock clock) {
requireNonNull(clock);
return clock instanceof NanoClock
? new Timer(System::nanoTime)
: new Timer(() -> nanos(clock));
} | [
"public",
"static",
"Timer",
"of",
"(",
"final",
"Clock",
"clock",
")",
"{",
"requireNonNull",
"(",
"clock",
")",
";",
"return",
"clock",
"instanceof",
"NanoClock",
"?",
"new",
"Timer",
"(",
"System",
"::",
"nanoTime",
")",
":",
"new",
"Timer",
"(",
"(",... | Return an new timer object which uses the given clock for measuring the
execution time.
@param clock the clock used for measuring the execution time
@return a new timer | [
"Return",
"an",
"new",
"timer",
"object",
"which",
"uses",
"the",
"given",
"clock",
"for",
"measuring",
"the",
"execution",
"time",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Timer.java#L86-L91 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/stat/Quantile.java | Quantile.adjustMarkerHeights | private void adjustMarkerHeights() {
double mm = _n[1] - 1.0;
double mp = _n[1] + 1.0;
if (_nn[0] >= mp && _n[2] > mp) {
_q[1] = qPlus(mp, _n[0], _n[1], _n[2], _q[0], _q[1], _q[2]);
_n[1] = mp;
} else if (_nn[0] <= mm && _n[0] < mm) {
_q[1] = qMinus(mm, _n[0], _n[1], _n[2], _q[0], _q[1], _q[2]);
_n[... | java | private void adjustMarkerHeights() {
double mm = _n[1] - 1.0;
double mp = _n[1] + 1.0;
if (_nn[0] >= mp && _n[2] > mp) {
_q[1] = qPlus(mp, _n[0], _n[1], _n[2], _q[0], _q[1], _q[2]);
_n[1] = mp;
} else if (_nn[0] <= mm && _n[0] < mm) {
_q[1] = qMinus(mm, _n[0], _n[1], _n[2], _q[0], _q[1], _q[2]);
_n[... | [
"private",
"void",
"adjustMarkerHeights",
"(",
")",
"{",
"double",
"mm",
"=",
"_n",
"[",
"1",
"]",
"-",
"1.0",
";",
"double",
"mp",
"=",
"_n",
"[",
"1",
"]",
"+",
"1.0",
";",
"if",
"(",
"_nn",
"[",
"0",
"]",
">=",
"mp",
"&&",
"_n",
"[",
"2",
... | Adjust heights of markers 0 to 2 if necessary | [
"Adjust",
"heights",
"of",
"markers",
"0",
"to",
"2",
"if",
"necessary"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/Quantile.java#L302-L332 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/BatchEvalKnapsack.java | BatchEvalKnapsack.batchEval | private static <G extends Gene<?, G>, C extends Comparable<? super C>>
ISeq<C> batchEval(
final Seq<Genotype<G>> genotypes,
final Function<? super Genotype<G>, ? extends C> function
) {
return genotypes.<C>map(function).asISeq();
} | java | private static <G extends Gene<?, G>, C extends Comparable<? super C>>
ISeq<C> batchEval(
final Seq<Genotype<G>> genotypes,
final Function<? super Genotype<G>, ? extends C> function
) {
return genotypes.<C>map(function).asISeq();
} | [
"private",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"ISeq",
"<",
"C",
">",
"batchEval",
"(",
"final",
"Seq",
"<",
"Genotype",
"<",
"G",
">",
">",
"genotyp... | Not really batch eval. Just for testing. | [
"Not",
"really",
"batch",
"eval",
".",
"Just",
"for",
"testing",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/BatchEvalKnapsack.java#L68-L74 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java | ConcatEngine.of | @SafeVarargs
public static <G extends Gene<?, G>, C extends Comparable<? super C>>
ConcatEngine<G, C> of(final EvolutionStreamable<G, C>... engines) {
return new ConcatEngine<>(Arrays.asList(engines));
} | java | @SafeVarargs
public static <G extends Gene<?, G>, C extends Comparable<? super C>>
ConcatEngine<G, C> of(final EvolutionStreamable<G, C>... engines) {
return new ConcatEngine<>(Arrays.asList(engines));
} | [
"@",
"SafeVarargs",
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"ConcatEngine",
"<",
"G",
",",
"C",
">",
"of",
"(",
"final",
"EvolutionStreamable",
"<"... | Create a new concatenating evolution engine with the given array of
engines.
@param engines the engines which are concatenated to <em>one</em> engine
@param <G> the gene type
@param <C> the fitness type
@return a new concatenating evolution engine
@throws NullPointerException if the {@code engines} or one of it's
elem... | [
"Create",
"a",
"new",
"concatenating",
"evolution",
"engine",
"with",
"the",
"given",
"array",
"of",
"engines",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java#L225-L229 | train |
jenetics/jenetics | jenetics.doc/src/main/java/TravelingSalesman.java | TravelingSalesman.of | public static TravelingSalesman of(int stops, double radius) {
final MSeq<double[]> points = MSeq.ofLength(stops);
final double delta = 2.0*PI/stops;
for (int i = 0; i < stops; ++i) {
final double alpha = delta*i;
final double x = cos(alpha)*radius + radius;
final double y = sin(alpha)*radius + radius;
... | java | public static TravelingSalesman of(int stops, double radius) {
final MSeq<double[]> points = MSeq.ofLength(stops);
final double delta = 2.0*PI/stops;
for (int i = 0; i < stops; ++i) {
final double alpha = delta*i;
final double x = cos(alpha)*radius + radius;
final double y = sin(alpha)*radius + radius;
... | [
"public",
"static",
"TravelingSalesman",
"of",
"(",
"int",
"stops",
",",
"double",
"radius",
")",
"{",
"final",
"MSeq",
"<",
"double",
"[",
"]",
">",
"points",
"=",
"MSeq",
".",
"ofLength",
"(",
"stops",
")",
";",
"final",
"double",
"delta",
"=",
"2.0"... | of stops. All stops lie on a circle with the given radius. | [
"of",
"stops",
".",
"All",
"stops",
"lie",
"on",
"a",
"circle",
"with",
"the",
"given",
"radius",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.doc/src/main/java/TravelingSalesman.java#L56-L77 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/Args.java | Args.arg | public Optional<String> arg(final String name) {
int index = _args.indexOf("--" + name);
if (index == -1) index = _args.indexOf("-" + name);
return index >= 0 && index < _args.length() - 1
? Optional.of(_args.get(index + 1))
: Optional.empty();
} | java | public Optional<String> arg(final String name) {
int index = _args.indexOf("--" + name);
if (index == -1) index = _args.indexOf("-" + name);
return index >= 0 && index < _args.length() - 1
? Optional.of(_args.get(index + 1))
: Optional.empty();
} | [
"public",
"Optional",
"<",
"String",
">",
"arg",
"(",
"final",
"String",
"name",
")",
"{",
"int",
"index",
"=",
"_args",
".",
"indexOf",
"(",
"\"--\"",
"+",
"name",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"index",
"=",
"_args",
".",
"i... | Return the parameter with the given name.
@param name the parameter name
@return the parameter with the given name, if any | [
"Return",
"the",
"parameter",
"with",
"the",
"given",
"name",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Args.java#L51-L58 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/Args.java | Args.intArg | public Optional<Integer> intArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Integer::valueOf));
} | java | public Optional<Integer> intArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Integer::valueOf));
} | [
"public",
"Optional",
"<",
"Integer",
">",
"intArg",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"arg",
"(",
"name",
")",
".",
"flatMap",
"(",
"s",
"->",
"parse",
"(",
"s",
",",
"Integer",
"::",
"valueOf",
")",
")",
";",
"}"
] | Return the int-argument with the given name.
@param name the argument name
@return the int argument value, if any | [
"Return",
"the",
"int",
"-",
"argument",
"with",
"the",
"given",
"name",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Args.java#L66-L69 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/Args.java | Args.longArg | public Optional<Long> longArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Long::valueOf));
} | java | public Optional<Long> longArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Long::valueOf));
} | [
"public",
"Optional",
"<",
"Long",
">",
"longArg",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"arg",
"(",
"name",
")",
".",
"flatMap",
"(",
"s",
"->",
"parse",
"(",
"s",
",",
"Long",
"::",
"valueOf",
")",
")",
";",
"}"
] | Return the long-argument with the given name.
@param name the argument name
@return the long argument value, if any | [
"Return",
"the",
"long",
"-",
"argument",
"with",
"the",
"given",
"name",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Args.java#L88-L91 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/Args.java | Args.doubleArg | public Optional<Double> doubleArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Double::valueOf));
} | java | public Optional<Double> doubleArg(final String name) {
return arg(name)
.flatMap(s -> parse(s, Double::valueOf));
} | [
"public",
"Optional",
"<",
"Double",
">",
"doubleArg",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"arg",
"(",
"name",
")",
".",
"flatMap",
"(",
"s",
"->",
"parse",
"(",
"s",
",",
"Double",
"::",
"valueOf",
")",
")",
";",
"}"
] | Return the double-argument with the given name.
@param name the argument name
@return the double argument value, if any | [
"Return",
"the",
"double",
"-",
"argument",
"with",
"the",
"given",
"name",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Args.java#L99-L102 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/stat/DoubleSummary.java | DoubleSummary.min | public static double min(final double[] values) {
double min = NaN;
if (values.length > 0) {
min = values[0];
for (int i = 0; i < values.length; ++i) {
if (values[i] < min) {
min = values[i];
}
}
}
return min;
} | java | public static double min(final double[] values) {
double min = NaN;
if (values.length > 0) {
min = values[0];
for (int i = 0; i < values.length; ++i) {
if (values[i] < min) {
min = values[i];
}
}
}
return min;
} | [
"public",
"static",
"double",
"min",
"(",
"final",
"double",
"[",
"]",
"values",
")",
"{",
"double",
"min",
"=",
"NaN",
";",
"if",
"(",
"values",
".",
"length",
">",
"0",
")",
"{",
"min",
"=",
"values",
"[",
"0",
"]",
";",
"for",
"(",
"int",
"i... | Return the minimum value of the given double array.
@since 4.0
@param values the double array.
@return the minimum value or {@link Double#NaN} if the given array is
empty.
@throws NullPointerException if the given array is {@code null}. | [
"Return",
"the",
"minimum",
"value",
"of",
"the",
"given",
"double",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/DoubleSummary.java#L243-L256 | train |
jenetics/jenetics | jenetics.xml/src/main/java/io/jenetics/xml/Readers.java | Readers.read | public static <
A,
G extends Gene<A, G>,
C extends Chromosome<G>
>
List<io.jenetics.Genotype<G>>
read(final InputStream in, final Reader<? extends C> chromosomeReader)
throws XMLStreamException
{
return Genotypes.read(in, chromosomeReader);
} | java | public static <
A,
G extends Gene<A, G>,
C extends Chromosome<G>
>
List<io.jenetics.Genotype<G>>
read(final InputStream in, final Reader<? extends C> chromosomeReader)
throws XMLStreamException
{
return Genotypes.read(in, chromosomeReader);
} | [
"public",
"static",
"<",
"A",
",",
"G",
"extends",
"Gene",
"<",
"A",
",",
"G",
">",
",",
"C",
"extends",
"Chromosome",
"<",
"G",
">",
">",
"List",
"<",
"io",
".",
"jenetics",
".",
"Genotype",
"<",
"G",
">",
">",
"read",
"(",
"final",
"InputStream... | Reads the genotypes by using the given chromosome reader.
@see Genotypes#read(InputStream, Reader)
@param <A> the allele type
@param <G> the gene type
@param <C> the chromosome type
@param in the input stream to read the genotype from
@param chromosomeReader the used chromosome reader
@return a genotype by using the ... | [
"Reads",
"the",
"genotypes",
"by",
"using",
"the",
"given",
"chromosome",
"reader",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.xml/src/main/java/io/jenetics/xml/Readers.java#L746-L756 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/CharacterChromosome.java | CharacterChromosome.toArray | public char[] toArray(final char[] array) {
final char[] a = array.length >= length() ?
array : new char[length()];
for (int i = length(); --i >= 0;) {
a[i] = charAt(i);
}
return a;
} | java | public char[] toArray(final char[] array) {
final char[] a = array.length >= length() ?
array : new char[length()];
for (int i = length(); --i >= 0;) {
a[i] = charAt(i);
}
return a;
} | [
"public",
"char",
"[",
"]",
"toArray",
"(",
"final",
"char",
"[",
"]",
"array",
")",
"{",
"final",
"char",
"[",
"]",
"a",
"=",
"array",
".",
"length",
">=",
"length",
"(",
")",
"?",
"array",
":",
"new",
"char",
"[",
"length",
"(",
")",
"]",
";"... | Returns an char array containing all of the elements in this chromosome
in proper sequence. If the chromosome fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the length of
this chromosome.
@since 3.0
@param array the array into which the elements of this chromosomes are ... | [
"Returns",
"an",
"char",
"array",
"containing",
"all",
"of",
"the",
"elements",
"in",
"this",
"chromosome",
"in",
"proper",
"sequence",
".",
"If",
"the",
"chromosome",
"fits",
"in",
"the",
"specified",
"array",
"it",
"is",
"returned",
"therein",
".",
"Otherw... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/CharacterChromosome.java#L192-L201 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/engine/AdaptiveEngine.java | AdaptiveEngine.of | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
AdaptiveEngine<G, C> of(
final Function<
? super EvolutionResult<G, C>,
? extends EvolutionStreamable<G, C>> engine
) {
return new AdaptiveEngine<>(engine);
} | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
AdaptiveEngine<G, C> of(
final Function<
? super EvolutionResult<G, C>,
? extends EvolutionStreamable<G, C>> engine
) {
return new AdaptiveEngine<>(engine);
} | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"AdaptiveEngine",
"<",
"G",
",",
"C",
">",
"of",
"(",
"final",
"Function",
"<",
"?",
"super",
"EvolutionR... | Return a new adaptive evolution engine, with the given engine generation
function.
@param engine the engine generating function used for adapting the engines.
<b>Be aware, that the {@code EvolutionResult} for the first created
{@code Engine} is {@code null}.</b>
@param <G> the gene type
@param <C> the fitness type
@re... | [
"Return",
"a",
"new",
"adaptive",
"evolution",
"engine",
"with",
"the",
"given",
"engine",
"generation",
"function",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/engine/AdaptiveEngine.java#L200-L207 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/PermutationChromosome.java | PermutationChromosome.ofInteger | public static PermutationChromosome<Integer>
ofInteger(final int start, final int end) {
if (end <= start) {
throw new IllegalArgumentException(format(
"end <= start: %d <= %d", end, start
));
}
return ofInteger(IntRange.of(start, end), end - start);
} | java | public static PermutationChromosome<Integer>
ofInteger(final int start, final int end) {
if (end <= start) {
throw new IllegalArgumentException(format(
"end <= start: %d <= %d", end, start
));
}
return ofInteger(IntRange.of(start, end), end - start);
} | [
"public",
"static",
"PermutationChromosome",
"<",
"Integer",
">",
"ofInteger",
"(",
"final",
"int",
"start",
",",
"final",
"int",
"end",
")",
"{",
"if",
"(",
"end",
"<=",
"start",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\... | Create an integer permutation chromosome with the given range.
@since 2.0
@param start the start of the integer range (inclusively) of the returned
chromosome.
@param end the end of the integer range (exclusively) of the returned
chromosome.
@return a integer permutation chromosome with the given integer range
values... | [
"Create",
"an",
"integer",
"permutation",
"chromosome",
"with",
"the",
"given",
"range",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/PermutationChromosome.java#L283-L292 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/PermutationChromosome.java | PermutationChromosome.ofInteger | public static PermutationChromosome<Integer>
ofInteger(final IntRange range, final int length) {
return of(
range.stream()
.boxed()
.collect(ISeq.toISeq()),
length
);
} | java | public static PermutationChromosome<Integer>
ofInteger(final IntRange range, final int length) {
return of(
range.stream()
.boxed()
.collect(ISeq.toISeq()),
length
);
} | [
"public",
"static",
"PermutationChromosome",
"<",
"Integer",
">",
"ofInteger",
"(",
"final",
"IntRange",
"range",
",",
"final",
"int",
"length",
")",
"{",
"return",
"of",
"(",
"range",
".",
"stream",
"(",
")",
".",
"boxed",
"(",
")",
".",
"collect",
"(",... | Create an integer permutation chromosome with the given range and length
@since 3.4
@param range the value range
@param length the chromosome length
@return a new integer permutation chromosome
@throws NullPointerException if the given {@code range} is {@code null}
@throws IllegalArgumentException if
{@code range.get... | [
"Create",
"an",
"integer",
"permutation",
"chromosome",
"with",
"the",
"given",
"range",
"and",
"length"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/PermutationChromosome.java#L309-L317 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/TravelingSalesman.java | TravelingSalesman.districtCapitals | private static ISeq<WayPoint> districtCapitals() throws IOException {
final String capitals = "/io/jenetics/example/DistrictCapitals.gpx";
try (InputStream in = TravelingSalesman
.class.getResourceAsStream(capitals))
{
return ISeq.of(GPX.read(in).getWayPoints());
}
} | java | private static ISeq<WayPoint> districtCapitals() throws IOException {
final String capitals = "/io/jenetics/example/DistrictCapitals.gpx";
try (InputStream in = TravelingSalesman
.class.getResourceAsStream(capitals))
{
return ISeq.of(GPX.read(in).getWayPoints());
}
} | [
"private",
"static",
"ISeq",
"<",
"WayPoint",
">",
"districtCapitals",
"(",
")",
"throws",
"IOException",
"{",
"final",
"String",
"capitals",
"=",
"\"/io/jenetics/example/DistrictCapitals.gpx\"",
";",
"try",
"(",
"InputStream",
"in",
"=",
"TravelingSalesman",
".",
"... | Return the district capitals, we want to visit. | [
"Return",
"the",
"district",
"capitals",
"we",
"want",
"to",
"visit",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/TravelingSalesman.java#L125-L132 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/EnumGene.java | EnumGene.of | public static <A> EnumGene<A> of(final ISeq<? extends A> validAlleles) {
return new EnumGene<>(
RandomRegistry.getRandom().nextInt(validAlleles.length()),
validAlleles
);
} | java | public static <A> EnumGene<A> of(final ISeq<? extends A> validAlleles) {
return new EnumGene<>(
RandomRegistry.getRandom().nextInt(validAlleles.length()),
validAlleles
);
} | [
"public",
"static",
"<",
"A",
">",
"EnumGene",
"<",
"A",
">",
"of",
"(",
"final",
"ISeq",
"<",
"?",
"extends",
"A",
">",
"validAlleles",
")",
"{",
"return",
"new",
"EnumGene",
"<>",
"(",
"RandomRegistry",
".",
"getRandom",
"(",
")",
".",
"nextInt",
"... | Return a new enum gene with an allele randomly chosen from the given
valid alleles.
@param <A> the allele type
@param validAlleles the sequence of valid alleles.
@return a new {@code EnumGene} with an randomly chosen allele from the
sequence of valid alleles
@throws java.lang.IllegalArgumentException if the give valid... | [
"Return",
"a",
"new",
"enum",
"gene",
"with",
"an",
"allele",
"randomly",
"chosen",
"from",
"the",
"given",
"valid",
"alleles",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/EnumGene.java#L224-L229 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/EnumGene.java | EnumGene.of | @SafeVarargs
public static <A> EnumGene<A> of(
final int alleleIndex,
final A... validAlleles
) {
return new EnumGene<>(alleleIndex, ISeq.of(validAlleles));
} | java | @SafeVarargs
public static <A> EnumGene<A> of(
final int alleleIndex,
final A... validAlleles
) {
return new EnumGene<>(alleleIndex, ISeq.of(validAlleles));
} | [
"@",
"SafeVarargs",
"public",
"static",
"<",
"A",
">",
"EnumGene",
"<",
"A",
">",
"of",
"(",
"final",
"int",
"alleleIndex",
",",
"final",
"A",
"...",
"validAlleles",
")",
"{",
"return",
"new",
"EnumGene",
"<>",
"(",
"alleleIndex",
",",
"ISeq",
".",
"of... | Create a new enum gene from the given valid genes and the chosen allele
index.
@param <A> the allele type
@param alleleIndex the index of the allele for this gene.
@param validAlleles the array of valid alleles.
@return a new {@code EnumGene} with the given with the allele
{@code validAlleles[alleleIndex]}
@throws jav... | [
"Create",
"a",
"new",
"enum",
"gene",
"from",
"the",
"given",
"valid",
"genes",
"and",
"the",
"chosen",
"allele",
"index",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/EnumGene.java#L243-L249 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/DoubleChromosome.java | DoubleChromosome.toArray | public double[] toArray(final double[] array) {
final double[] a = array.length >= length() ? array : new double[length()];
for (int i = length(); --i >= 0;) {
a[i] = doubleValue(i);
}
return a;
} | java | public double[] toArray(final double[] array) {
final double[] a = array.length >= length() ? array : new double[length()];
for (int i = length(); --i >= 0;) {
a[i] = doubleValue(i);
}
return a;
} | [
"public",
"double",
"[",
"]",
"toArray",
"(",
"final",
"double",
"[",
"]",
"array",
")",
"{",
"final",
"double",
"[",
"]",
"a",
"=",
"array",
".",
"length",
">=",
"length",
"(",
")",
"?",
"array",
":",
"new",
"double",
"[",
"length",
"(",
")",
"]... | Returns an double array containing all of the elements in this chromosome
in proper sequence. If the chromosome fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the length of
this chromosome.
@since 3.0
@param array the array into which the elements of this chromosomes ar... | [
"Returns",
"an",
"double",
"array",
"containing",
"all",
"of",
"the",
"elements",
"in",
"this",
"chromosome",
"in",
"proper",
"sequence",
".",
"If",
"the",
"chromosome",
"fits",
"in",
"the",
"specified",
"array",
"it",
"is",
"returned",
"therein",
".",
"Othe... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/DoubleChromosome.java#L167-L174 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java | ParetoFront.toParetoFront | public static <C extends Comparable<? super C>>
Collector<C, ?, ParetoFront<C>> toParetoFront() {
return toParetoFront(Comparator.naturalOrder());
} | java | public static <C extends Comparable<? super C>>
Collector<C, ?, ParetoFront<C>> toParetoFront() {
return toParetoFront(Comparator.naturalOrder());
} | [
"public",
"static",
"<",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Collector",
"<",
"C",
",",
"?",
",",
"ParetoFront",
"<",
"C",
">",
">",
"toParetoFront",
"(",
")",
"{",
"return",
"toParetoFront",
"(",
"Comparator",
".",
"natura... | Return a pareto-front collector. The natural order of the elements is
used as pareto-dominance order.
@param <C> the element type
@return a new pareto-front collector | [
"Return",
"a",
"pareto",
"-",
"front",
"collector",
".",
"The",
"natural",
"order",
"of",
"the",
"elements",
"is",
"used",
"as",
"pareto",
"-",
"dominance",
"order",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java#L228-L231 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Limits.java | Limits.byFitnessThreshold | public static <C extends Comparable<? super C>>
Predicate<EvolutionResult<?, C>> byFitnessThreshold(final C threshold) {
return new FitnessThresholdLimit<>(threshold);
} | java | public static <C extends Comparable<? super C>>
Predicate<EvolutionResult<?, C>> byFitnessThreshold(final C threshold) {
return new FitnessThresholdLimit<>(threshold);
} | [
"public",
"static",
"<",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Predicate",
"<",
"EvolutionResult",
"<",
"?",
",",
"C",
">",
">",
"byFitnessThreshold",
"(",
"final",
"C",
"threshold",
")",
"{",
"return",
"new",
"FitnessThresholdLi... | Return a predicate, which will truncated the evolution stream if the
best fitness of the current population becomes less than the specified
threshold and the objective is set to minimize the fitness. This
predicate also stops the evolution if the best fitness in the current
population becomes greater than the user-spec... | [
"Return",
"a",
"predicate",
"which",
"will",
"truncated",
"the",
"evolution",
"stream",
"if",
"the",
"best",
"fitness",
"of",
"the",
"current",
"population",
"becomes",
"less",
"than",
"the",
"specified",
"threshold",
"and",
"the",
"objective",
"is",
"set",
"t... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Limits.java#L203-L206 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Limits.java | Limits.byFitnessConvergence | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>> byFitnessConvergence(
final int shortFilterSize,
final int longFilterSize,
final BiPredicate<DoubleMoments, DoubleMoments> proceed
) {
return new FitnessConvergenceLimit<>(
shortFilterSize,
longFilterSize,
proce... | java | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>> byFitnessConvergence(
final int shortFilterSize,
final int longFilterSize,
final BiPredicate<DoubleMoments, DoubleMoments> proceed
) {
return new FitnessConvergenceLimit<>(
shortFilterSize,
longFilterSize,
proce... | [
"public",
"static",
"<",
"N",
"extends",
"Number",
"&",
"Comparable",
"<",
"?",
"super",
"N",
">",
">",
"Predicate",
"<",
"EvolutionResult",
"<",
"?",
",",
"N",
">",
">",
"byFitnessConvergence",
"(",
"final",
"int",
"shortFilterSize",
",",
"final",
"int",
... | Return a predicate, which will truncate the evolution stream if the
fitness is converging. Two filters of different lengths are used to
smooth the best fitness across the generations.
<pre>{@code
final Phenotype<DoubleGene, Double> result = engine.stream()
.limit(byFitnessConvergence(5, 15, (s, l) -> {
final double di... | [
"Return",
"a",
"predicate",
"which",
"will",
"truncate",
"the",
"evolution",
"stream",
"if",
"the",
"fitness",
"is",
"converging",
".",
"Two",
"filters",
"of",
"different",
"lengths",
"are",
"used",
"to",
"smooth",
"the",
"best",
"fitness",
"across",
"the",
... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Limits.java#L245-L256 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Limits.java | Limits.byFitnessConvergence | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>> byFitnessConvergence(
final int shortFilterSize,
final int longFilterSize,
final double epsilon
) {
if (epsilon < 0.0 || epsilon > 1.0) {
throw new IllegalArgumentException(format(
"The given epsilon is not in the... | java | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>> byFitnessConvergence(
final int shortFilterSize,
final int longFilterSize,
final double epsilon
) {
if (epsilon < 0.0 || epsilon > 1.0) {
throw new IllegalArgumentException(format(
"The given epsilon is not in the... | [
"public",
"static",
"<",
"N",
"extends",
"Number",
"&",
"Comparable",
"<",
"?",
"super",
"N",
">",
">",
"Predicate",
"<",
"EvolutionResult",
"<",
"?",
",",
"N",
">",
">",
"byFitnessConvergence",
"(",
"final",
"int",
"shortFilterSize",
",",
"final",
"int",
... | Return a predicate, which will truncate the evolution stream if the
fitness is converging. Two filters of different lengths are used to
smooth the best fitness across the generations. When the smoothed best
fitness from the long filter is less than a user-specified percentage
away from the smoothed best fitness from th... | [
"Return",
"a",
"predicate",
"which",
"will",
"truncate",
"the",
"evolution",
"stream",
"if",
"the",
"fitness",
"is",
"converging",
".",
"Two",
"filters",
"of",
"different",
"lengths",
"are",
"used",
"to",
"smooth",
"the",
"best",
"fitness",
"across",
"the",
... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Limits.java#L299-L316 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Limits.java | Limits.eps | private static double eps(final double s, final double l) {
final double div = max(abs(s), abs(l));
return abs(s - l)/(div <= 10E-20 ? 1.0 : div);
} | java | private static double eps(final double s, final double l) {
final double div = max(abs(s), abs(l));
return abs(s - l)/(div <= 10E-20 ? 1.0 : div);
} | [
"private",
"static",
"double",
"eps",
"(",
"final",
"double",
"s",
",",
"final",
"double",
"l",
")",
"{",
"final",
"double",
"div",
"=",
"max",
"(",
"abs",
"(",
"s",
")",
",",
"abs",
"(",
"l",
")",
")",
";",
"return",
"abs",
"(",
"s",
"-",
"l",... | Calculate the relative mean difference between short and long filter. | [
"Calculate",
"the",
"relative",
"mean",
"difference",
"between",
"short",
"and",
"long",
"filter",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Limits.java#L319-L322 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Limits.java | Limits.byPopulationConvergence | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>>
byPopulationConvergence(final double epsilon) {
if (epsilon < 0.0 || epsilon > 1.0) {
throw new IllegalArgumentException(format(
"The given epsilon is not in the range [0, 1]: %f", epsilon
));
}
return new Popul... | java | public static <N extends Number & Comparable<? super N>>
Predicate<EvolutionResult<?, N>>
byPopulationConvergence(final double epsilon) {
if (epsilon < 0.0 || epsilon > 1.0) {
throw new IllegalArgumentException(format(
"The given epsilon is not in the range [0, 1]: %f", epsilon
));
}
return new Popul... | [
"public",
"static",
"<",
"N",
"extends",
"Number",
"&",
"Comparable",
"<",
"?",
"super",
"N",
">",
">",
"Predicate",
"<",
"EvolutionResult",
"<",
"?",
",",
"N",
">",
">",
"byPopulationConvergence",
"(",
"final",
"double",
"epsilon",
")",
"{",
"if",
"(",
... | A termination method that stops the evolution when the population is
deemed as converged. The population is deemed as converged when the
average fitness across the current population is less than a
user-specified percentage away from the best fitness of the current
population.
@since 3.9
@param epsilon the maximal re... | [
"A",
"termination",
"method",
"that",
"stops",
"the",
"evolution",
"when",
"the",
"population",
"is",
"deemed",
"as",
"converged",
".",
"The",
"population",
"is",
"deemed",
"as",
"converged",
"when",
"the",
"average",
"fitness",
"across",
"the",
"current",
"po... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Limits.java#L367-L379 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/CompositeAlterer.java | CompositeAlterer.of | @SafeVarargs
static <G extends Gene<?, G>, C extends Comparable<? super C>>
CompositeAlterer<G, C> of(final Alterer<G, C>... alterers) {
return new CompositeAlterer<>(ISeq.of(alterers));
} | java | @SafeVarargs
static <G extends Gene<?, G>, C extends Comparable<? super C>>
CompositeAlterer<G, C> of(final Alterer<G, C>... alterers) {
return new CompositeAlterer<>(ISeq.of(alterers));
} | [
"@",
"SafeVarargs",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"CompositeAlterer",
"<",
"G",
",",
"C",
">",
"of",
"(",
"final",
"Alterer",
"<",
"G",
",",
"C... | Combine the given alterers.
@param <G> the gene type
@param <C> the fitness function result type
@param alterers the alterers to combine.
@return a new alterer which consists of the given one
@throws NullPointerException if one of the alterers is {@code null}. | [
"Combine",
"the",
"given",
"alterers",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/CompositeAlterer.java#L135-L139 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/CompositeAlterer.java | CompositeAlterer.join | static <T extends Gene<?, T>, C extends Comparable<? super C>>
CompositeAlterer<T, C> join(
final Alterer<T, C> a1,
final Alterer<T, C> a2
) {
return CompositeAlterer.of(a1, a2);
} | java | static <T extends Gene<?, T>, C extends Comparable<? super C>>
CompositeAlterer<T, C> join(
final Alterer<T, C> a1,
final Alterer<T, C> a2
) {
return CompositeAlterer.of(a1, a2);
} | [
"static",
"<",
"T",
"extends",
"Gene",
"<",
"?",
",",
"T",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"CompositeAlterer",
"<",
"T",
",",
"C",
">",
"join",
"(",
"final",
"Alterer",
"<",
"T",
",",
"C",
">",
"a1",
",... | Joins the given alterer and returns a new CompositeAlterer object. If one
of the given alterers is a CompositeAlterer the sub alterers of it are
unpacked and appended to the newly created CompositeAlterer.
@param <T> the gene type of the alterers.
@param <C> the fitness function result type
@param a1 the first altere... | [
"Joins",
"the",
"given",
"alterer",
"and",
"returns",
"a",
"new",
"CompositeAlterer",
"object",
".",
"If",
"one",
"of",
"the",
"given",
"alterers",
"is",
"a",
"CompositeAlterer",
"the",
"sub",
"alterers",
"of",
"it",
"are",
"unpacked",
"and",
"appended",
"to... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/CompositeAlterer.java#L154-L160 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Phenotype.java | Phenotype.newInstance | @Deprecated
public Phenotype<G, C> newInstance(
final long generation,
final Function<? super Genotype<G>, ? extends C> function,
final Function<? super C, ? extends C> scaler
) {
return of(_genotype, generation, function, scaler);
} | java | @Deprecated
public Phenotype<G, C> newInstance(
final long generation,
final Function<? super Genotype<G>, ? extends C> function,
final Function<? super C, ? extends C> scaler
) {
return of(_genotype, generation, function, scaler);
} | [
"@",
"Deprecated",
"public",
"Phenotype",
"<",
"G",
",",
"C",
">",
"newInstance",
"(",
"final",
"long",
"generation",
",",
"final",
"Function",
"<",
"?",
"super",
"Genotype",
"<",
"G",
">",
",",
"?",
"extends",
"C",
">",
"function",
",",
"final",
"Func... | Return a new phenotype with the the genotype of this and with new
fitness function, fitness scaler and generation.
@param generation the generation of the new phenotype.
@param function the (new) fitness scaler of the created phenotype.
@param scaler the (new) fitness scaler of the created phenotype
@return a new phen... | [
"Return",
"a",
"new",
"phenotype",
"with",
"the",
"the",
"genotype",
"of",
"this",
"and",
"with",
"new",
"fitness",
"function",
"fitness",
"scaler",
"and",
"generation",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Phenotype.java#L349-L356 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Phenotype.java | Phenotype.newInstance | @Deprecated
public Phenotype<G, C> newInstance(
final long generation,
final Function<? super Genotype<G>, ? extends C> function
) {
return of(_genotype, generation, function, a -> a);
} | java | @Deprecated
public Phenotype<G, C> newInstance(
final long generation,
final Function<? super Genotype<G>, ? extends C> function
) {
return of(_genotype, generation, function, a -> a);
} | [
"@",
"Deprecated",
"public",
"Phenotype",
"<",
"G",
",",
"C",
">",
"newInstance",
"(",
"final",
"long",
"generation",
",",
"final",
"Function",
"<",
"?",
"super",
"Genotype",
"<",
"G",
">",
",",
"?",
"extends",
"C",
">",
"function",
")",
"{",
"return",... | Return a new phenotype with the the genotype of this and with new
fitness function and generation.
@param generation the generation of the new phenotype.
@param function the (new) fitness scaler of the created phenotype.
@return a new phenotype with the given values.
@throws NullPointerException if one of the values i... | [
"Return",
"a",
"new",
"phenotype",
"with",
"the",
"the",
"genotype",
"of",
"this",
"and",
"with",
"new",
"fitness",
"function",
"and",
"generation",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Phenotype.java#L371-L377 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Phenotype.java | Phenotype.of | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Phenotype<G, C> of(
final Genotype<G> genotype,
final long generation,
final Function<? super Genotype<G>, ? extends C> function,
final Function<? super C, ? extends C> scaler
) {
return new Phenotype<>(
genotype,
generation,
fun... | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Phenotype<G, C> of(
final Genotype<G> genotype,
final long generation,
final Function<? super Genotype<G>, ? extends C> function,
final Function<? super C, ? extends C> scaler
) {
return new Phenotype<>(
genotype,
generation,
fun... | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Phenotype",
"<",
"G",
",",
"C",
">",
"of",
"(",
"final",
"Genotype",
"<",
"G",
">",
"genotype",
",",
... | Create a new phenotype from the given arguments.
@param <G> the gene type of the chromosome
@param <C> the fitness value type
@param genotype the genotype of this phenotype.
@param generation the current generation of the generated phenotype.
@param function the fitness function of this phenotype.
@param scaler the fi... | [
"Create",
"a",
"new",
"phenotype",
"from",
"the",
"given",
"arguments",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Phenotype.java#L423-L437 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/internal/util/TreePattern.java | TreePattern.compile | public static TreePattern compile(final String pattern) {
return new TreePattern(TreeNode.parse(pattern, Decl::of));
} | java | public static TreePattern compile(final String pattern) {
return new TreePattern(TreeNode.parse(pattern, Decl::of));
} | [
"public",
"static",
"TreePattern",
"compile",
"(",
"final",
"String",
"pattern",
")",
"{",
"return",
"new",
"TreePattern",
"(",
"TreeNode",
".",
"parse",
"(",
"pattern",
",",
"Decl",
"::",
"of",
")",
")",
";",
"}"
] | Compiles the given tree pattern string.
@param pattern the tree pattern string
@return the compiled pattern
@throws NullPointerException if the given pattern is {@code null}
@throws IllegalArgumentException if the given parentheses tree string
doesn't represent a valid pattern tree | [
"Compiles",
"the",
"given",
"tree",
"pattern",
"string",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/internal/util/TreePattern.java#L328-L330 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/collection/Array.java | Array.sort | public void sort(
final int from,
final int until,
final Comparator<? super T> comparator
) {
_store.sort(from + _start, until + _start, comparator);
} | java | public void sort(
final int from,
final int until,
final Comparator<? super T> comparator
) {
_store.sort(from + _start, until + _start, comparator);
} | [
"public",
"void",
"sort",
"(",
"final",
"int",
"from",
",",
"final",
"int",
"until",
",",
"final",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"_store",
".",
"sort",
"(",
"from",
"+",
"_start",
",",
"until",
"+",
"_start",
",",... | Sort the store.
@param from the start index where to start sorting (inclusively)
@param until the end index where to stop sorting (exclusively)
@param comparator the {@code Comparator} used to compare sequence
elements. A {@code null} value indicates that the elements'
Comparable natural ordering should be used | [
"Sort",
"the",
"store",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/collection/Array.java#L126-L132 | train |
jenetics/jenetics | jenetics.tool/src/main/java/io/jenetics/tool/trial/TrialMeter.java | TrialMeter.of | public static <T> TrialMeter<T> of(
final String name,
final String description,
final Params<T> params,
final String... dataSetNames
) {
return new TrialMeter<T>(
name,
description,
Env.of(),
params,
DataSet.of(params.size(), dataSetNames)
);
} | java | public static <T> TrialMeter<T> of(
final String name,
final String description,
final Params<T> params,
final String... dataSetNames
) {
return new TrialMeter<T>(
name,
description,
Env.of(),
params,
DataSet.of(params.size(), dataSetNames)
);
} | [
"public",
"static",
"<",
"T",
">",
"TrialMeter",
"<",
"T",
">",
"of",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"description",
",",
"final",
"Params",
"<",
"T",
">",
"params",
",",
"final",
"String",
"...",
"dataSetNames",
")",
"{",
"retu... | Return a new trial measure environment.
@param name the trial meter name
@param description the trial meter description, maybe {@code null}
@param params the parameters which are tested by this trial meter
@param dataSetNames the names of the calculated data sets
@param <T> the parameter type
@return a new trial measu... | [
"Return",
"a",
"new",
"trial",
"measure",
"environment",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/TrialMeter.java#L211-L224 | train |
jenetics/jenetics | jenetics.doc/src/main/java/OnesCounting.java | OnesCounting.count | private static Integer count(final Genotype<BitGene> gt) {
return gt.getChromosome()
.as(BitChromosome.class)
.bitCount();
} | java | private static Integer count(final Genotype<BitGene> gt) {
return gt.getChromosome()
.as(BitChromosome.class)
.bitCount();
} | [
"private",
"static",
"Integer",
"count",
"(",
"final",
"Genotype",
"<",
"BitGene",
">",
"gt",
")",
"{",
"return",
"gt",
".",
"getChromosome",
"(",
")",
".",
"as",
"(",
"BitChromosome",
".",
"class",
")",
".",
"bitCount",
"(",
")",
";",
"}"
] | This method calculates the fitness for a given genotype. | [
"This",
"method",
"calculates",
"the",
"fitness",
"for",
"a",
"given",
"genotype",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.doc/src/main/java/OnesCounting.java#L17-L21 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionStatistics.java | EvolutionStatistics.accept | private void accept(final EvolutionDurations durations) {
final double selection =
toSeconds(durations.getOffspringSelectionDuration()) +
toSeconds(durations.getSurvivorsSelectionDuration());
final double alter =
toSeconds(durations.getOffspringAlterDuration()) +
toSeconds(durations.getOffspringFilter... | java | private void accept(final EvolutionDurations durations) {
final double selection =
toSeconds(durations.getOffspringSelectionDuration()) +
toSeconds(durations.getSurvivorsSelectionDuration());
final double alter =
toSeconds(durations.getOffspringAlterDuration()) +
toSeconds(durations.getOffspringFilter... | [
"private",
"void",
"accept",
"(",
"final",
"EvolutionDurations",
"durations",
")",
"{",
"final",
"double",
"selection",
"=",
"toSeconds",
"(",
"durations",
".",
"getOffspringSelectionDuration",
"(",
")",
")",
"+",
"toSeconds",
"(",
"durations",
".",
"getSurvivorsS... | Calculate duration statistics | [
"Calculate",
"duration",
"statistics"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionStatistics.java#L136-L150 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/EvolutionResume.java | EvolutionResume.run | private EvolutionResult<BitGene, Double> run(
final EvolutionResult<BitGene, Double> last,
final AtomicBoolean proceed
) {
System.out.println("Starting evolution with existing result.");
return (last != null ? ENGINE.stream(last) : ENGINE.stream())
.limit(r -> proceed.get())
.collect(EvolutionResult.toB... | java | private EvolutionResult<BitGene, Double> run(
final EvolutionResult<BitGene, Double> last,
final AtomicBoolean proceed
) {
System.out.println("Starting evolution with existing result.");
return (last != null ? ENGINE.stream(last) : ENGINE.stream())
.limit(r -> proceed.get())
.collect(EvolutionResult.toB... | [
"private",
"EvolutionResult",
"<",
"BitGene",
",",
"Double",
">",
"run",
"(",
"final",
"EvolutionResult",
"<",
"BitGene",
",",
"Double",
">",
"last",
",",
"final",
"AtomicBoolean",
"proceed",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Starting e... | Run the evolution. | [
"Run",
"the",
"evolution",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/EvolutionResume.java#L61-L70 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/stat/DoubleMomentStatistics.java | DoubleMomentStatistics.accept | @Override
public void accept(final double value) {
super.accept(value);
_min = Math.min(_min, value);
_max = Math.max(_max, value);
_sum.add(value);
} | java | @Override
public void accept(final double value) {
super.accept(value);
_min = Math.min(_min, value);
_max = Math.max(_max, value);
_sum.add(value);
} | [
"@",
"Override",
"public",
"void",
"accept",
"(",
"final",
"double",
"value",
")",
"{",
"super",
".",
"accept",
"(",
"value",
")",
";",
"_min",
"=",
"Math",
".",
"min",
"(",
"_min",
",",
"value",
")",
";",
"_max",
"=",
"Math",
".",
"max",
"(",
"_... | Records a new value into the moments information
@param value the input {@code value} | [
"Records",
"a",
"new",
"value",
"into",
"the",
"moments",
"information"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/DoubleMomentStatistics.java#L91-L97 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/BitChromosome.java | BitChromosome.toBitSet | public BitSet toBitSet() {
final BitSet set = new BitSet(length());
for (int i = 0, n = length(); i < n; ++i) {
set.set(i, getGene(i).getBit());
}
return set;
} | java | public BitSet toBitSet() {
final BitSet set = new BitSet(length());
for (int i = 0, n = length(); i < n; ++i) {
set.set(i, getGene(i).getBit());
}
return set;
} | [
"public",
"BitSet",
"toBitSet",
"(",
")",
"{",
"final",
"BitSet",
"set",
"=",
"new",
"BitSet",
"(",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"length",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
... | Return the corresponding BitSet of this BitChromosome.
@return The corresponding BitSet of this BitChromosome. | [
"Return",
"the",
"corresponding",
"BitSet",
"of",
"this",
"BitChromosome",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/BitChromosome.java#L358-L364 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/BitChromosome.java | BitChromosome.invert | public BitChromosome invert() {
final byte[] data = _genes.clone();
bit.invert(data);
return new BitChromosome(data, _length, 1.0 - _p);
} | java | public BitChromosome invert() {
final byte[] data = _genes.clone();
bit.invert(data);
return new BitChromosome(data, _length, 1.0 - _p);
} | [
"public",
"BitChromosome",
"invert",
"(",
")",
"{",
"final",
"byte",
"[",
"]",
"data",
"=",
"_genes",
".",
"clone",
"(",
")",
";",
"bit",
".",
"invert",
"(",
"data",
")",
";",
"return",
"new",
"BitChromosome",
"(",
"data",
",",
"_length",
",",
"1.0",... | Invert the ones and zeros of this bit chromosome.
@return a new BitChromosome with inverted ones and zeros. | [
"Invert",
"the",
"ones",
"and",
"zeros",
"of",
"this",
"bit",
"chromosome",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/BitChromosome.java#L450-L454 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/BitChromosome.java | BitChromosome.of | public static BitChromosome of(final int length, final double p) {
return new BitChromosome(bit.newArray(length, p), length, p);
} | java | public static BitChromosome of(final int length, final double p) {
return new BitChromosome(bit.newArray(length, p), length, p);
} | [
"public",
"static",
"BitChromosome",
"of",
"(",
"final",
"int",
"length",
",",
"final",
"double",
"p",
")",
"{",
"return",
"new",
"BitChromosome",
"(",
"bit",
".",
"newArray",
"(",
"length",
",",
"p",
")",
",",
"length",
",",
"p",
")",
";",
"}"
] | Construct a new BitChromosome with the given _length.
@param length Length of the BitChromosome, number of bits.
@param p Probability of the TRUEs in the BitChromosome.
@return a new {@code BitChromosome} with the given parameter
@throws NegativeArraySizeException if the {@code length} is smaller
than one.
@throws Ill... | [
"Construct",
"a",
"new",
"BitChromosome",
"with",
"the",
"given",
"_length",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/BitChromosome.java#L466-L468 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java | IntList.forEach | public void forEach(final IntConsumer action) {
requireNonNull(action);
final int size = _size;
for (int i = 0; i < size; ++i) {
action.accept(_data[i]);
}
} | java | public void forEach(final IntConsumer action) {
requireNonNull(action);
final int size = _size;
for (int i = 0; i < size; ++i) {
action.accept(_data[i]);
}
} | [
"public",
"void",
"forEach",
"(",
"final",
"IntConsumer",
"action",
")",
"{",
"requireNonNull",
"(",
"action",
")",
";",
"final",
"int",
"size",
"=",
"_size",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"++",
"i",
")",
"{",
... | Performs the given action for each element of the list.
@param action the action to be performed for each element
@throws NullPointerException if the specified action is {@code null} | [
"Performs",
"the",
"given",
"action",
"for",
"each",
"element",
"of",
"the",
"list",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java#L93-L100 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java | IntList.addAll | public boolean addAll(final int[] elements) {
final int count = elements.length;
ensureSize(_size + count);
arraycopy(elements, 0, _data, _size, count);
_size += count;
return count != 0;
} | java | public boolean addAll(final int[] elements) {
final int count = elements.length;
ensureSize(_size + count);
arraycopy(elements, 0, _data, _size, count);
_size += count;
return count != 0;
} | [
"public",
"boolean",
"addAll",
"(",
"final",
"int",
"[",
"]",
"elements",
")",
"{",
"final",
"int",
"count",
"=",
"elements",
".",
"length",
";",
"ensureSize",
"(",
"_size",
"+",
"count",
")",
";",
"arraycopy",
"(",
"elements",
",",
"0",
",",
"_data",
... | Appends all of the elements in the specified array to the end of this
list.
@param elements array containing elements to be added to this list
@return <tt>true</tt> if this list changed as a result of the call
@throws NullPointerException if the specified array is null | [
"Appends",
"all",
"of",
"the",
"elements",
"in",
"the",
"specified",
"array",
"to",
"the",
"end",
"of",
"this",
"list",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java#L153-L160 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java | IntList.addAll | public boolean addAll(final int index, final int[] elements) {
addRangeCheck(index);
final int count = elements.length;
ensureSize(_size + count);
final int moved = _size - index;
if (moved > 0) {
arraycopy(_data, index, _data, index + count, moved);
}
arraycopy(elements, 0, _data, index, count);
... | java | public boolean addAll(final int index, final int[] elements) {
addRangeCheck(index);
final int count = elements.length;
ensureSize(_size + count);
final int moved = _size - index;
if (moved > 0) {
arraycopy(_data, index, _data, index + count, moved);
}
arraycopy(elements, 0, _data, index, count);
... | [
"public",
"boolean",
"addAll",
"(",
"final",
"int",
"index",
",",
"final",
"int",
"[",
"]",
"elements",
")",
"{",
"addRangeCheck",
"(",
"index",
")",
";",
"final",
"int",
"count",
"=",
"elements",
".",
"length",
";",
"ensureSize",
"(",
"_size",
"+",
"c... | Inserts all of the elements in the specified array into this list,
starting at the specified position.
@param index index at which to insert the first element from the
specified collection
@param elements collection containing elements to be added to this list
@return <tt>true</tt> if this list changed as a result of ... | [
"Inserts",
"all",
"of",
"the",
"elements",
"in",
"the",
"specified",
"array",
"into",
"this",
"list",
"starting",
"at",
"the",
"specified",
"position",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/internal/IntList.java#L174-L188 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/AbstractTreeGene.java | AbstractTreeGene.getChild | @Override
public G getChild(final int index) {
checkTreeState();
if (index < 0 || index >= childCount()) {
throw new IndexOutOfBoundsException(format(
"Child index out of bounds: %s", index
));
}
assert _genes != null;
return _genes.get(_childOffset + index);
} | java | @Override
public G getChild(final int index) {
checkTreeState();
if (index < 0 || index >= childCount()) {
throw new IndexOutOfBoundsException(format(
"Child index out of bounds: %s", index
));
}
assert _genes != null;
return _genes.get(_childOffset + index);
} | [
"@",
"Override",
"public",
"G",
"getChild",
"(",
"final",
"int",
"index",
")",
"{",
"checkTreeState",
"(",
")",
";",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"childCount",
"(",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
... | Return the child gene with the given index.
@param index the child index
@return the child node with the given index
@throws IndexOutOfBoundsException if the {@code index} is out of
bounds ({@code [0, childCount())})
@throws IllegalStateException if this gene is not part of a chromosome | [
"Return",
"the",
"child",
"gene",
"with",
"the",
"given",
"index",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/AbstractTreeGene.java#L162-L173 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Mutator.java | Mutator.mutate | @SuppressWarnings("deprecation")
protected MutatorResult<Phenotype<G, C>> mutate(
final Phenotype<G, C> phenotype,
final long generation,
final double p,
final Random random
) {
return mutate(phenotype.getGenotype(), p, random)
.map(gt -> phenotype.newInstance(gt, generation));
} | java | @SuppressWarnings("deprecation")
protected MutatorResult<Phenotype<G, C>> mutate(
final Phenotype<G, C> phenotype,
final long generation,
final double p,
final Random random
) {
return mutate(phenotype.getGenotype(), p, random)
.map(gt -> phenotype.newInstance(gt, generation));
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"protected",
"MutatorResult",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"mutate",
"(",
"final",
"Phenotype",
"<",
"G",
",",
"C",
">",
"phenotype",
",",
"final",
"long",
"generation",
",",
"final",... | Mutates the given phenotype.
@see #mutate(Genotype, double, Random)
@see #mutate(Chromosome, double, Random)
@see #mutate(Gene, Random)
@param phenotype the phenotype to mutate
@param generation the actual generation
@param p the mutation probability for the underlying genetic objects
@param random the random engine ... | [
"Mutates",
"the",
"given",
"phenotype",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Mutator.java#L144-L153 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/Mutator.java | Mutator.mutate | protected MutatorResult<Genotype<G>> mutate(
final Genotype<G> genotype,
final double p,
final Random random
) {
final int P = probability.toInt(p);
final ISeq<MutatorResult<Chromosome<G>>> result = genotype.toSeq()
.map(gt -> random.nextInt() < P
? mutate(gt, p, random)
: MutatorResult.of(gt));
... | java | protected MutatorResult<Genotype<G>> mutate(
final Genotype<G> genotype,
final double p,
final Random random
) {
final int P = probability.toInt(p);
final ISeq<MutatorResult<Chromosome<G>>> result = genotype.toSeq()
.map(gt -> random.nextInt() < P
? mutate(gt, p, random)
: MutatorResult.of(gt));
... | [
"protected",
"MutatorResult",
"<",
"Genotype",
"<",
"G",
">",
">",
"mutate",
"(",
"final",
"Genotype",
"<",
"G",
">",
"genotype",
",",
"final",
"double",
"p",
",",
"final",
"Random",
"random",
")",
"{",
"final",
"int",
"P",
"=",
"probability",
".",
"to... | Mutates the given genotype.
@see #mutate(Chromosome, double, Random)
@see #mutate(Gene, Random)
@param genotype the genotype to mutate
@param p the mutation probability for the underlying genetic objects
@param random the random engine used for the genotype mutation
@return the mutation result | [
"Mutates",
"the",
"given",
"genotype",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/Mutator.java#L166-L181 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java | EvolvingImagesWorker.start | public void start(
final BiConsumer<
EvolutionResult<PolygonGene, Double>,
EvolutionResult<PolygonGene, Double>> callback
) {
final Thread thread = new Thread(() -> {
final MinMax<EvolutionResult<PolygonGene, Double>> best = MinMax.of();
_engine.stream()
.limit(result -> !Thread.currentThread().is... | java | public void start(
final BiConsumer<
EvolutionResult<PolygonGene, Double>,
EvolutionResult<PolygonGene, Double>> callback
) {
final Thread thread = new Thread(() -> {
final MinMax<EvolutionResult<PolygonGene, Double>> best = MinMax.of();
_engine.stream()
.limit(result -> !Thread.currentThread().is... | [
"public",
"void",
"start",
"(",
"final",
"BiConsumer",
"<",
"EvolutionResult",
"<",
"PolygonGene",
",",
"Double",
">",
",",
"EvolutionResult",
"<",
"PolygonGene",
",",
"Double",
">",
">",
"callback",
")",
"{",
"final",
"Thread",
"thread",
"=",
"new",
"Thread... | Starts the evolution worker with the given evolution result callback. The
callback may be null.
@param callback the {@code EvolutionResult} callback. The first parameter
contains the current result and the second the best. | [
"Starts",
"the",
"evolution",
"worker",
"with",
"the",
"given",
"evolution",
"result",
"callback",
".",
"The",
"callback",
"may",
"be",
"null",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java#L163-L183 | train |
jenetics/jenetics | jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java | EvolvingImagesWorker.stop | public void stop() {
resume();
final Thread thread = _thread;
if (thread != null) {
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
_thread = null;
}
}
} | java | public void stop() {
resume();
final Thread thread = _thread;
if (thread != null) {
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
_thread = null;
}
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"resume",
"(",
")",
";",
"final",
"Thread",
"thread",
"=",
"_thread",
";",
"if",
"(",
"thread",
"!=",
"null",
")",
"{",
"thread",
".",
"interrupt",
"(",
")",
";",
"try",
"{",
"thread",
".",
"join",
"(",
")... | Stops the current evolution, if running. | [
"Stops",
"the",
"current",
"evolution",
"if",
"running",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java#L203-L216 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/AltererResult.java | AltererResult.of | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
AltererResult<G, C> of(
final ISeq<Phenotype<G, C>> population,
final int alterations
) {
return new AltererResult<>(population, alterations);
} | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
AltererResult<G, C> of(
final ISeq<Phenotype<G, C>> population,
final int alterations
) {
return new AltererResult<>(population, alterations);
} | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"AltererResult",
"<",
"G",
",",
"C",
">",
"of",
"(",
"final",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
... | Return a new alter result for the given arguments.
@param population the altered population
@param alterations the number of altered individuals
@param <G> the gene type
@param <C> the result type
@return a new alterer for the given arguments
@throws NullPointerException if the given population is {@code null}
@throws... | [
"Return",
"a",
"new",
"alter",
"result",
"for",
"the",
"given",
"arguments",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/AltererResult.java#L120-L126 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/LongChromosome.java | LongChromosome.toArray | public long[] toArray(final long[] array) {
final long[] a = array.length >= length() ? array : new long[length()];
for (int i = length(); --i >= 0;) {
a[i] = longValue(i);
}
return a;
} | java | public long[] toArray(final long[] array) {
final long[] a = array.length >= length() ? array : new long[length()];
for (int i = length(); --i >= 0;) {
a[i] = longValue(i);
}
return a;
} | [
"public",
"long",
"[",
"]",
"toArray",
"(",
"final",
"long",
"[",
"]",
"array",
")",
"{",
"final",
"long",
"[",
"]",
"a",
"=",
"array",
".",
"length",
">=",
"length",
"(",
")",
"?",
"array",
":",
"new",
"long",
"[",
"length",
"(",
")",
"]",
";"... | Returns an long array containing all of the elements in this chromosome
in proper sequence. If the chromosome fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the length of
this chromosome.
@since 3.0
@param array the array into which the elements of this chromosomes are ... | [
"Returns",
"an",
"long",
"array",
"containing",
"all",
"of",
"the",
"elements",
"in",
"this",
"chromosome",
"in",
"proper",
"sequence",
".",
"If",
"the",
"chromosome",
"fits",
"in",
"the",
"specified",
"array",
"it",
"is",
"returned",
"therein",
".",
"Otherw... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/LongChromosome.java#L167-L174 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java | MathExpr.eval | public double eval(final double... args) {
final double val = apply(
DoubleStream.of(args)
.boxed()
.toArray(Double[]::new)
);
return val == -0.0 ? 0.0 : val;
} | java | public double eval(final double... args) {
final double val = apply(
DoubleStream.of(args)
.boxed()
.toArray(Double[]::new)
);
return val == -0.0 ? 0.0 : val;
} | [
"public",
"double",
"eval",
"(",
"final",
"double",
"...",
"args",
")",
"{",
"final",
"double",
"val",
"=",
"apply",
"(",
"DoubleStream",
".",
"of",
"(",
"args",
")",
".",
"boxed",
"(",
")",
".",
"toArray",
"(",
"Double",
"[",
"]",
"::",
"new",
")"... | Convenient method, which lets you apply the program function without
explicitly create a wrapper array.
<pre>{@code
final double result = MathExpr.parse("2*z + 3*x - y").eval(3, 2, 1);
assert result == 9.0;
}</pre>
@see #apply(Double[])
@see #eval(String, double...)
@param args the function arguments
@return the eva... | [
"Convenient",
"method",
"which",
"lets",
"you",
"apply",
"the",
"program",
"function",
"without",
"explicitly",
"create",
"a",
"wrapper",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java#L148-L155 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java | MathExpr.simplify | public static Tree<? extends Op<Double>, ?>
simplify(final Tree<? extends Op<Double>, ?> tree) {
return MathExprRewriter.prune(TreeNode.ofTree(tree));
} | java | public static Tree<? extends Op<Double>, ?>
simplify(final Tree<? extends Op<Double>, ?> tree) {
return MathExprRewriter.prune(TreeNode.ofTree(tree));
} | [
"public",
"static",
"Tree",
"<",
"?",
"extends",
"Op",
"<",
"Double",
">",
",",
"?",
">",
"simplify",
"(",
"final",
"Tree",
"<",
"?",
"extends",
"Op",
"<",
"Double",
">",
",",
"?",
">",
"tree",
")",
"{",
"return",
"MathExprRewriter",
".",
"prune",
... | Tries to simplify the given math tree.
<pre>{@code
final Tree<? extends Op<Double>, ?> tree =
MathExpr.parseTree("4.0 + 4.0 + x*(5.0 + 13.0)");
final Tree<? extends Op<Double>, ?> simplified = MathExpr.simplify(tree)
System.out.println(simplified);
}</pre>
The simplified tree will be look like this:
<pre> {@code
add
├... | [
"Tries",
"to",
"simplify",
"the",
"given",
"math",
"tree",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java#L408-L411 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/TreeCrossover.java | TreeCrossover.crossover | private <A> void crossover(
final MSeq<Chromosome<G>> c1,
final MSeq<Chromosome<G>> c2,
final int index
) {
@SuppressWarnings("unchecked")
final TreeNode<A> tree1 = (TreeNode<A>)TreeNode.ofTree(c1.get(index).getGene());
@SuppressWarnings("unchecked")
final TreeNode<A> tree2 = (TreeNode<A>)TreeNode.ofTree... | java | private <A> void crossover(
final MSeq<Chromosome<G>> c1,
final MSeq<Chromosome<G>> c2,
final int index
) {
@SuppressWarnings("unchecked")
final TreeNode<A> tree1 = (TreeNode<A>)TreeNode.ofTree(c1.get(index).getGene());
@SuppressWarnings("unchecked")
final TreeNode<A> tree2 = (TreeNode<A>)TreeNode.ofTree... | [
"private",
"<",
"A",
">",
"void",
"crossover",
"(",
"final",
"MSeq",
"<",
"Chromosome",
"<",
"G",
">",
">",
"c1",
",",
"final",
"MSeq",
"<",
"Chromosome",
"<",
"G",
">",
">",
"c2",
",",
"final",
"int",
"index",
")",
"{",
"@",
"SuppressWarnings",
"(... | the abstract "crossover" method usually don't have to do additional casts. | [
"the",
"abstract",
"crossover",
"method",
"usually",
"don",
"t",
"have",
"to",
"do",
"additional",
"casts",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/TreeCrossover.java#L105-L128 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java | Const.of | public static <T> Const<T> of(final String name, final T value) {
return new Const<>(requireNonNull(name), value);
} | java | public static <T> Const<T> of(final String name, final T value) {
return new Const<>(requireNonNull(name), value);
} | [
"public",
"static",
"<",
"T",
">",
"Const",
"<",
"T",
">",
"of",
"(",
"final",
"String",
"name",
",",
"final",
"T",
"value",
")",
"{",
"return",
"new",
"Const",
"<>",
"(",
"requireNonNull",
"(",
"name",
")",
",",
"value",
")",
";",
"}"
] | Return a new constant with the given name and value.
@param name the constant name
@param value the constant value
@param <T> the constant type
@return a new constant
@throws NullPointerException if the given constant {@code name} is
{@code null} | [
"Return",
"a",
"new",
"constant",
"with",
"the",
"given",
"name",
"and",
"value",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java#L119-L121 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/CharacterGene.java | CharacterGene.of | public static CharacterGene of(final CharSeq validCharacters) {
return new CharacterGene(
validCharacters,
RandomRegistry.getRandom().nextInt(validCharacters.length())
);
} | java | public static CharacterGene of(final CharSeq validCharacters) {
return new CharacterGene(
validCharacters,
RandomRegistry.getRandom().nextInt(validCharacters.length())
);
} | [
"public",
"static",
"CharacterGene",
"of",
"(",
"final",
"CharSeq",
"validCharacters",
")",
"{",
"return",
"new",
"CharacterGene",
"(",
"validCharacters",
",",
"RandomRegistry",
".",
"getRandom",
"(",
")",
".",
"nextInt",
"(",
"validCharacters",
".",
"length",
"... | Create a new CharacterGene with a randomly chosen character from the
set of valid characters.
@param validCharacters the valid characters for this gene.
@return a new valid, <em>random</em> gene,
@throws NullPointerException if the {@code validCharacters} are
{@code null}. | [
"Create",
"a",
"new",
"CharacterGene",
"with",
"a",
"randomly",
"chosen",
"character",
"from",
"the",
"set",
"of",
"valid",
"characters",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/CharacterGene.java#L201-L206 | train |
jenetics/jenetics | jenetics.tool/src/main/java/io/jenetics/tool/evaluation/Diagram.java | Diagram.create | public static void create(
final Path input,
final Template template,
final Params<?> params,
final Path output,
final SampleSummary summary,
final SampleSummary... summaries
)
throws IOException
{
final Stream<SampleSummary> summaryStream = Stream.concat(
Stream.of(summary), Stream.of(summaries)
... | java | public static void create(
final Path input,
final Template template,
final Params<?> params,
final Path output,
final SampleSummary summary,
final SampleSummary... summaries
)
throws IOException
{
final Stream<SampleSummary> summaryStream = Stream.concat(
Stream.of(summary), Stream.of(summaries)
... | [
"public",
"static",
"void",
"create",
"(",
"final",
"Path",
"input",
",",
"final",
"Template",
"template",
",",
"final",
"Params",
"<",
"?",
">",
"params",
",",
"final",
"Path",
"output",
",",
"final",
"SampleSummary",
"summary",
",",
"final",
"SampleSummary... | Create a performance diagram.
@param input the input data
@param template the Gnuplot template to use
@param params the diagram parameters (x-axis)
@param output the output file
@param summary the first summary data
@param summaries the rest of the summary data
@throws IOException if the diagram generation fails
@thro... | [
"Create",
"a",
"performance",
"diagram",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/evaluation/Diagram.java#L146-L187 | train |
jenetics/jenetics | jenetics.tool/src/main/java/io/jenetics/tool/trial/Data.java | Data.summary | public SampleSummary summary() {
return _samples.stream()
.filter(Sample::isFull)
.collect(toSampleSummary(sampleSize()));
} | java | public SampleSummary summary() {
return _samples.stream()
.filter(Sample::isFull)
.collect(toSampleSummary(sampleSize()));
} | [
"public",
"SampleSummary",
"summary",
"(",
")",
"{",
"return",
"_samples",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"Sample",
"::",
"isFull",
")",
".",
"collect",
"(",
"toSampleSummary",
"(",
"sampleSize",
"(",
")",
")",
")",
";",
"}"
] | Calculate the sample summary of this data object.
@return the sample summary of this data object | [
"Calculate",
"the",
"sample",
"summary",
"of",
"this",
"data",
"object",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/Data.java#L127-L131 | train |
jenetics/jenetics | jenetics.tool/src/main/java/io/jenetics/tool/trial/Params.java | Params.of | public static <T> Params<T> of(
final String name,
final ISeq<T> params
) {
return new Params<>(name, params);
} | java | public static <T> Params<T> of(
final String name,
final ISeq<T> params
) {
return new Params<>(name, params);
} | [
"public",
"static",
"<",
"T",
">",
"Params",
"<",
"T",
">",
"of",
"(",
"final",
"String",
"name",
",",
"final",
"ISeq",
"<",
"T",
">",
"params",
")",
"{",
"return",
"new",
"Params",
"<>",
"(",
"name",
",",
"params",
")",
";",
"}"
] | Return a new parameters object.
@param name the name of the parameters
@param params the actual parameters
@param <T> the parameter type
@throws NullPointerException if one of the parameters is {@code null}
@return a new parameters object | [
"Return",
"a",
"new",
"parameters",
"object",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.tool/src/main/java/io/jenetics/tool/trial/Params.java#L134-L139 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/AnyGene.java | AnyGene.seq | static <A> ISeq<AnyGene<A>> seq(
final IntRange lengthRange,
final Supplier<? extends A> supplier,
final Predicate<? super A> validator
) {
return MSeq.<AnyGene<A>>ofLength(random.nextInt(lengthRange, getRandom()))
.fill(() -> of(supplier.get(), supplier, validator))
.toISeq();
} | java | static <A> ISeq<AnyGene<A>> seq(
final IntRange lengthRange,
final Supplier<? extends A> supplier,
final Predicate<? super A> validator
) {
return MSeq.<AnyGene<A>>ofLength(random.nextInt(lengthRange, getRandom()))
.fill(() -> of(supplier.get(), supplier, validator))
.toISeq();
} | [
"static",
"<",
"A",
">",
"ISeq",
"<",
"AnyGene",
"<",
"A",
">",
">",
"seq",
"(",
"final",
"IntRange",
"lengthRange",
",",
"final",
"Supplier",
"<",
"?",
"extends",
"A",
">",
"supplier",
",",
"final",
"Predicate",
"<",
"?",
"super",
"A",
">",
"validat... | Create gene sequence. | [
"Create",
"gene",
"sequence",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/AnyGene.java#L209-L217 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/bit.java | bit.swap | public static void swap(
final byte[] data, final int start, final int end,
final byte[] otherData, final int otherStart
) {
for (int i = end - start; --i >= 0;) {
final boolean temp = get(data, i + start);
set(data, i + start, get(otherData, otherStart + i));
set(otherData, otherStart + i, temp);
}
... | java | public static void swap(
final byte[] data, final int start, final int end,
final byte[] otherData, final int otherStart
) {
for (int i = end - start; --i >= 0;) {
final boolean temp = get(data, i + start);
set(data, i + start, get(otherData, otherStart + i));
set(otherData, otherStart + i, temp);
}
... | [
"public",
"static",
"void",
"swap",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
",",
"final",
"byte",
"[",
"]",
"otherData",
",",
"final",
"int",
"otherStart",
")",
"{",
"for",
"(",
"int",
"i",
... | Swap a given range with a range of the same size with another array.
<pre>
start end
| |
data: +---+---+---+---+---+---+---+---+---+---+---+---+
+---------------+
+---------------+
otherData: +---+---+---+---+---+---+---+---+---+---+---+---+
|
otherStart
</pre>
@param data the first byte... | [
"Swap",
"a",
"given",
"range",
"with",
"a",
"range",
"of",
"the",
"same",
"size",
"with",
"another",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L177-L186 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/bit.java | bit.flip | public static byte[] flip(final byte[] data, final int index) {
return get(data, index) ? unset(data, index) : set(data, index);
} | java | public static byte[] flip(final byte[] data, final int index) {
return get(data, index) ? unset(data, index) : set(data, index);
} | [
"public",
"static",
"byte",
"[",
"]",
"flip",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"index",
")",
"{",
"return",
"get",
"(",
"data",
",",
"index",
")",
"?",
"unset",
"(",
"data",
",",
"index",
")",
":",
"set",
"(",
"data",
... | Flip the bit at the given index.
@param data the data array.
@param index the index of the bit to flip.
@return the input array, for command chaining
@throws IndexOutOfBoundsException if the index is
{@code index >= max || index < 0}.
@throws NullPointerException if the {@code data} array is {@code null}. | [
"Flip",
"the",
"bit",
"at",
"the",
"given",
"index",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L342-L344 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/bit.java | bit.copy | public static byte[] copy(final byte[] data, final int start, final int end) {
if (start > end) {
throw new IllegalArgumentException(String.format(
"start > end: %d > %d", start, end
));
}
if (start < 0 || start > data.length << 3) {
throw new ArrayIndexOutOfBoundsException(String.format(
"%d < 0... | java | public static byte[] copy(final byte[] data, final int start, final int end) {
if (start > end) {
throw new IllegalArgumentException(String.format(
"start > end: %d > %d", start, end
));
}
if (start < 0 || start > data.length << 3) {
throw new ArrayIndexOutOfBoundsException(String.format(
"%d < 0... | [
"public",
"static",
"byte",
"[",
"]",
"copy",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"start",
",",
"final",
"int",
"end",
")",
"{",
"if",
"(",
"start",
">",
"end",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"Stri... | Copies the specified range of the specified array into a new array.
@param data the bits from which a range is to be copied
@param start the initial index of the range to be copied, inclusive
@param end the final index of the range to be copied, exclusive.
@return a new array containing the specified range from the or... | [
"Copies",
"the",
"specified",
"range",
"of",
"the",
"specified",
"array",
"into",
"a",
"new",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/bit.java#L376-L413 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/MutatorResult.java | MutatorResult.of | public static <T> MutatorResult<T> of(final T result, final int mutations) {
return new MutatorResult<>(result, mutations);
} | java | public static <T> MutatorResult<T> of(final T result, final int mutations) {
return new MutatorResult<>(result, mutations);
} | [
"public",
"static",
"<",
"T",
">",
"MutatorResult",
"<",
"T",
">",
"of",
"(",
"final",
"T",
"result",
",",
"final",
"int",
"mutations",
")",
"{",
"return",
"new",
"MutatorResult",
"<>",
"(",
"result",
",",
"mutations",
")",
";",
"}"
] | Create a new mutation result with the given values.
@param result the mutation result
@param mutations the number of mutations
@param <T> the mutation result type
@return a new mutation result
@throws IllegalArgumentException if the given {@code mutations} is
negative
@throws NullPointerException if the given mutation... | [
"Create",
"a",
"new",
"mutation",
"result",
"with",
"the",
"given",
"values",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/MutatorResult.java#L106-L108 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/SwapMutator.java | SwapMutator.mutate | @Override
protected MutatorResult<Chromosome<G>> mutate(
final Chromosome<G> chromosome,
final double p,
final Random random
) {
final MutatorResult<Chromosome<G>> result;
if (chromosome.length() > 1) {
final MSeq<G> genes = chromosome.toSeq().copy();
final int mutations = (int)indexes(random, genes.l... | java | @Override
protected MutatorResult<Chromosome<G>> mutate(
final Chromosome<G> chromosome,
final double p,
final Random random
) {
final MutatorResult<Chromosome<G>> result;
if (chromosome.length() > 1) {
final MSeq<G> genes = chromosome.toSeq().copy();
final int mutations = (int)indexes(random, genes.l... | [
"@",
"Override",
"protected",
"MutatorResult",
"<",
"Chromosome",
"<",
"G",
">",
">",
"mutate",
"(",
"final",
"Chromosome",
"<",
"G",
">",
"chromosome",
",",
"final",
"double",
"p",
",",
"final",
"Random",
"random",
")",
"{",
"final",
"MutatorResult",
"<",... | Swaps the genes in the given array, with the mutation probability of this
mutation. | [
"Swaps",
"the",
"genes",
"in",
"the",
"given",
"array",
"with",
"the",
"mutation",
"probability",
"of",
"this",
"mutation",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/SwapMutator.java#L70-L91 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/require.java | require.nonNegative | public static double nonNegative(final double value, final String message) {
if (value < 0) {
throw new IllegalArgumentException(format(
"%s must not be negative: %f.", message, value
));
}
return value;
} | java | public static double nonNegative(final double value, final String message) {
if (value < 0) {
throw new IllegalArgumentException(format(
"%s must not be negative: %f.", message, value
));
}
return value;
} | [
"public",
"static",
"double",
"nonNegative",
"(",
"final",
"double",
"value",
",",
"final",
"String",
"message",
")",
"{",
"if",
"(",
"value",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\"%s must not be negative: %f.\"",... | Check if the specified value is not negative.
@param value the value to check.
@param message the exception message.
@return the given value.
@throws IllegalArgumentException if {@code value < 0}. | [
"Check",
"if",
"the",
"specified",
"value",
"is",
"not",
"negative",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/require.java#L42-L49 | train |
jenetics/jenetics | jenetics.doc/src/main/java/Knapsack.java | Knapsack.fitness | static Function<ISeq<Item>, Double>
fitness(final double size) {
return items -> {
final Item sum = items.stream().collect(Item.toSum());
return sum.size <= size ? sum.value : 0;
};
} | java | static Function<ISeq<Item>, Double>
fitness(final double size) {
return items -> {
final Item sum = items.stream().collect(Item.toSum());
return sum.size <= size ? sum.value : 0;
};
} | [
"static",
"Function",
"<",
"ISeq",
"<",
"Item",
">",
",",
"Double",
">",
"fitness",
"(",
"final",
"double",
"size",
")",
"{",
"return",
"items",
"->",
"{",
"final",
"Item",
"sum",
"=",
"items",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Item",
... | Creating the fitness function. | [
"Creating",
"the",
"fitness",
"function",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.doc/src/main/java/Knapsack.java#L56-L62 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/stat/DoubleMoments.java | DoubleMoments.of | public static DoubleMoments of(
final long count,
final double min,
final double max,
final double sum,
final double mean,
final double variance,
final double skewness,
final double kurtosis
) {
return new DoubleMoments(
count,
min,
max,
sum,
mean,
variance,
skewness,
kurtosis... | java | public static DoubleMoments of(
final long count,
final double min,
final double max,
final double sum,
final double mean,
final double variance,
final double skewness,
final double kurtosis
) {
return new DoubleMoments(
count,
min,
max,
sum,
mean,
variance,
skewness,
kurtosis... | [
"public",
"static",
"DoubleMoments",
"of",
"(",
"final",
"long",
"count",
",",
"final",
"double",
"min",
",",
"final",
"double",
"max",
",",
"final",
"double",
"sum",
",",
"final",
"double",
"mean",
",",
"final",
"double",
"variance",
",",
"final",
"double... | Create an immutable object which contains statistical values.
@param count the count of values recorded
@param min the minimum value
@param max the maximum value
@param sum the sum of the recorded values
@param mean the arithmetic mean of values
@param variance the variance of values
@param skewness the skewness of va... | [
"Create",
"an",
"immutable",
"object",
"which",
"contains",
"statistical",
"values",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/stat/DoubleMoments.java#L222-L242 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java | ProgramChromosome.create | private static <A> ProgramChromosome<A> create(
final Tree<? extends Op<A>, ?> program,
final Predicate<? super ProgramChromosome<A>> validator,
final ISeq<? extends Op<A>> operations,
final ISeq<? extends Op<A>> terminals
) {
final ISeq<ProgramGene<A>> genes = FlatTreeNode.of(program).stream()
.map(n -> ... | java | private static <A> ProgramChromosome<A> create(
final Tree<? extends Op<A>, ?> program,
final Predicate<? super ProgramChromosome<A>> validator,
final ISeq<? extends Op<A>> operations,
final ISeq<? extends Op<A>> terminals
) {
final ISeq<ProgramGene<A>> genes = FlatTreeNode.of(program).stream()
.map(n -> ... | [
"private",
"static",
"<",
"A",
">",
"ProgramChromosome",
"<",
"A",
">",
"create",
"(",
"final",
"Tree",
"<",
"?",
"extends",
"Op",
"<",
"A",
">",
",",
"?",
">",
"program",
",",
"final",
"Predicate",
"<",
"?",
"super",
"ProgramChromosome",
"<",
"A",
"... | Create the chromosomes without checks. | [
"Create",
"the",
"chromosomes",
"without",
"checks",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java#L212-L224 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java | TreeParser.tokenize | static List<Token> tokenize(final String value) {
final List<Token> tokens = new ArrayList<>();
char pc = '\0';
int pos = 0;
final StringBuilder token = new StringBuilder();
for (int i = 0; i < value.length(); ++i) {
final char c = value.charAt(i);
if (isTokenSeparator(c) && pc != ESCAPE_CHAR) {
t... | java | static List<Token> tokenize(final String value) {
final List<Token> tokens = new ArrayList<>();
char pc = '\0';
int pos = 0;
final StringBuilder token = new StringBuilder();
for (int i = 0; i < value.length(); ++i) {
final char c = value.charAt(i);
if (isTokenSeparator(c) && pc != ESCAPE_CHAR) {
t... | [
"static",
"List",
"<",
"Token",
">",
"tokenize",
"(",
"final",
"String",
"value",
")",
"{",
"final",
"List",
"<",
"Token",
">",
"tokens",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"char",
"pc",
"=",
"'",
"'",
";",
"int",
"pos",
"=",
"0",
";",... | Tokenize the given parentheses string.
@param value the parentheses string
@return the parentheses string tokens
@throws NullPointerException if the given {@code value} is {@code null} | [
"Tokenize",
"the",
"given",
"parentheses",
"string",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java#L63-L89 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java | TreeParser.parse | static <B> TreeNode<B> parse(
final String value,
final Function<? super String, ? extends B> mapper
) {
requireNonNull(value);
requireNonNull(mapper);
final TreeNode<B> root = TreeNode.of();
final Deque<TreeNode<B>> parents = new ArrayDeque<>();
TreeNode<B> current = root;
for (Token token : tokeniz... | java | static <B> TreeNode<B> parse(
final String value,
final Function<? super String, ? extends B> mapper
) {
requireNonNull(value);
requireNonNull(mapper);
final TreeNode<B> root = TreeNode.of();
final Deque<TreeNode<B>> parents = new ArrayDeque<>();
TreeNode<B> current = root;
for (Token token : tokeniz... | [
"static",
"<",
"B",
">",
"TreeNode",
"<",
"B",
">",
"parse",
"(",
"final",
"String",
"value",
",",
"final",
"Function",
"<",
"?",
"super",
"String",
",",
"?",
"extends",
"B",
">",
"mapper",
")",
"{",
"requireNonNull",
"(",
"value",
")",
";",
"require... | Parses the given parentheses tree string
@since 4.3
@param <B> the tree node value type
@param value the parentheses tree string
@param mapper the mapper which converts the serialized string value to
the desired type
@return the parsed tree object
@throws NullPointerException if one of the arguments is {@code null}
@... | [
"Parses",
"the",
"given",
"parentheses",
"tree",
"string"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeParser.java#L109-L179 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java | ProgramGene.newInstance | @Override
public ProgramGene<A> newInstance(final Op<A> op) {
if (getValue().arity() != op.arity()) {
throw new IllegalArgumentException(format(
"New operation must have same arity: %s[%d] != %s[%d]",
getValue().name(), getValue().arity(), op.name(), op.arity()
));
}
return new ProgramGene<>(op, ch... | java | @Override
public ProgramGene<A> newInstance(final Op<A> op) {
if (getValue().arity() != op.arity()) {
throw new IllegalArgumentException(format(
"New operation must have same arity: %s[%d] != %s[%d]",
getValue().name(), getValue().arity(), op.name(), op.arity()
));
}
return new ProgramGene<>(op, ch... | [
"@",
"Override",
"public",
"ProgramGene",
"<",
"A",
">",
"newInstance",
"(",
"final",
"Op",
"<",
"A",
">",
"op",
")",
"{",
"if",
"(",
"getValue",
"(",
")",
".",
"arity",
"(",
")",
"!=",
"op",
".",
"arity",
"(",
")",
")",
"{",
"throw",
"new",
"I... | Create a new program gene with the given operation.
@param op the operation of the new program gene
@return a new program gene with the given operation
@throws NullPointerException if the given {@code op} is {@code null}
@throws IllegalArgumentException if the arity of the given operation is
different from the arity o... | [
"Create",
"a",
"new",
"program",
"gene",
"with",
"the",
"given",
"operation",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java#L170-L179 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Engine.java | Engine.selectSurvivors | private ISeq<Phenotype<G, C>>
selectSurvivors(final ISeq<Phenotype<G, C>> population) {
return _survivorsCount > 0
?_survivorsSelector.select(population, _survivorsCount, _optimize)
: ISeq.empty();
} | java | private ISeq<Phenotype<G, C>>
selectSurvivors(final ISeq<Phenotype<G, C>> population) {
return _survivorsCount > 0
?_survivorsSelector.select(population, _survivorsCount, _optimize)
: ISeq.empty();
} | [
"private",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"selectSurvivors",
"(",
"final",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"population",
")",
"{",
"return",
"_survivorsCount",
">",
"0",
"?",
"_survivorsSelector",
".",
"... | Selects the survivors population. A new population object is returned. | [
"Selects",
"the",
"survivors",
"population",
".",
"A",
"new",
"population",
"object",
"is",
"returned",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L373-L378 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Engine.java | Engine.selectOffspring | private ISeq<Phenotype<G, C>>
selectOffspring(final ISeq<Phenotype<G, C>> population) {
return _offspringCount > 0
? _offspringSelector.select(population, _offspringCount, _optimize)
: ISeq.empty();
} | java | private ISeq<Phenotype<G, C>>
selectOffspring(final ISeq<Phenotype<G, C>> population) {
return _offspringCount > 0
? _offspringSelector.select(population, _offspringCount, _optimize)
: ISeq.empty();
} | [
"private",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"selectOffspring",
"(",
"final",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"population",
")",
"{",
"return",
"_offspringCount",
">",
"0",
"?",
"_offspringSelector",
".",
"... | Selects the offspring population. A new population object is returned. | [
"Selects",
"the",
"offspring",
"population",
".",
"A",
"new",
"population",
"object",
"is",
"returned",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L381-L386 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Engine.java | Engine.filter | private FilterResult<G, C> filter(
final Seq<Phenotype<G, C>> population,
final long generation
) {
int killCount = 0;
int invalidCount = 0;
final MSeq<Phenotype<G, C>> pop = MSeq.of(population);
for (int i = 0, n = pop.size(); i < n; ++i) {
final Phenotype<G, C> individual = pop.get(i);
if (!_vali... | java | private FilterResult<G, C> filter(
final Seq<Phenotype<G, C>> population,
final long generation
) {
int killCount = 0;
int invalidCount = 0;
final MSeq<Phenotype<G, C>> pop = MSeq.of(population);
for (int i = 0, n = pop.size(); i < n; ++i) {
final Phenotype<G, C> individual = pop.get(i);
if (!_vali... | [
"private",
"FilterResult",
"<",
"G",
",",
"C",
">",
"filter",
"(",
"final",
"Seq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"population",
",",
"final",
"long",
"generation",
")",
"{",
"int",
"killCount",
"=",
"0",
";",
"int",
"invalidCount",
"... | Filters out invalid and old individuals. Filtering is done in place. | [
"Filters",
"out",
"invalid",
"and",
"old",
"individuals",
".",
"Filtering",
"is",
"done",
"in",
"place",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L389-L410 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/Engine.java | Engine.newPhenotype | private Phenotype<G, C> newPhenotype(final long generation) {
int count = 0;
Phenotype<G, C> phenotype;
do {
phenotype = Phenotype.of(
_genotypeFactory.newInstance(),
generation,
_fitnessFunction,
_fitnessScaler
);
} while (++count < _individualCreationRetries &&
!_validator.test(pheno... | java | private Phenotype<G, C> newPhenotype(final long generation) {
int count = 0;
Phenotype<G, C> phenotype;
do {
phenotype = Phenotype.of(
_genotypeFactory.newInstance(),
generation,
_fitnessFunction,
_fitnessScaler
);
} while (++count < _individualCreationRetries &&
!_validator.test(pheno... | [
"private",
"Phenotype",
"<",
"G",
",",
"C",
">",
"newPhenotype",
"(",
"final",
"long",
"generation",
")",
"{",
"int",
"count",
"=",
"0",
";",
"Phenotype",
"<",
"G",
",",
"C",
">",
"phenotype",
";",
"do",
"{",
"phenotype",
"=",
"Phenotype",
".",
"of",... | Create a new and valid phenotype | [
"Create",
"a",
"new",
"and",
"valid",
"phenotype"
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/Engine.java#L413-L427 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java | Program.eval | @SafeVarargs
public static <T> T eval(
final Tree<? extends Op<T>, ?> tree,
final T... variables
) {
requireNonNull(tree);
requireNonNull(variables);
final Op<T> op = tree.getValue();
return op.isTerminal()
? eval(op, variables)
: eval(op,
tree.childStream()
.map(child -> eval(child, var... | java | @SafeVarargs
public static <T> T eval(
final Tree<? extends Op<T>, ?> tree,
final T... variables
) {
requireNonNull(tree);
requireNonNull(variables);
final Op<T> op = tree.getValue();
return op.isTerminal()
? eval(op, variables)
: eval(op,
tree.childStream()
.map(child -> eval(child, var... | [
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"T",
"eval",
"(",
"final",
"Tree",
"<",
"?",
"extends",
"Op",
"<",
"T",
">",
",",
"?",
">",
"tree",
",",
"final",
"T",
"...",
"variables",
")",
"{",
"requireNonNull",
"(",
"tree",
")",
";",
"... | Evaluates the given operation tree with the given variables.
@param <T> the argument type
@param tree the operation tree
@param variables the input variables
@return the result of the operation tree evaluation
@throws NullPointerException if one of the arguments is {@code null}
@throws IllegalArgumentException if the ... | [
"Evaluates",
"the",
"given",
"operation",
"tree",
"with",
"the",
"given",
"variables",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L164-L180 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java | Program.check | public static void check(final Tree<? extends Op<?>, ?> program) {
requireNonNull(program);
program.forEach(Program::checkArity);
} | java | public static void check(final Tree<? extends Op<?>, ?> program) {
requireNonNull(program);
program.forEach(Program::checkArity);
} | [
"public",
"static",
"void",
"check",
"(",
"final",
"Tree",
"<",
"?",
"extends",
"Op",
"<",
"?",
">",
",",
"?",
">",
"program",
")",
"{",
"requireNonNull",
"(",
"program",
")",
";",
"program",
".",
"forEach",
"(",
"Program",
"::",
"checkArity",
")",
"... | Validates the given program tree.
@param program the program to validate
@throws NullPointerException if the given {@code program} is {@code null}
@throws IllegalArgumentException if the given operation tree is invalid,
which means there is at least one node where the operation arity
and the node child count differ. | [
"Validates",
"the",
"given",
"program",
"tree",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L207-L210 | train |
jenetics/jenetics | jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java | Program.offsets | static int[]
offsets(final ISeq<? extends FlatTree<? extends Op<?>, ?>> nodes) {
final int[] offsets = new int[nodes.size()];
int offset = 1;
for (int i = 0; i < offsets.length; ++i) {
final Op<?> op = nodes.get(i).getValue();
offsets[i] = op.isTerminal() ? -1 : offset;
offset += op.arity();
}
re... | java | static int[]
offsets(final ISeq<? extends FlatTree<? extends Op<?>, ?>> nodes) {
final int[] offsets = new int[nodes.size()];
int offset = 1;
for (int i = 0; i < offsets.length; ++i) {
final Op<?> op = nodes.get(i).getValue();
offsets[i] = op.isTerminal() ? -1 : offset;
offset += op.arity();
}
re... | [
"static",
"int",
"[",
"]",
"offsets",
"(",
"final",
"ISeq",
"<",
"?",
"extends",
"FlatTree",
"<",
"?",
"extends",
"Op",
"<",
"?",
">",
",",
"?",
">",
">",
"nodes",
")",
"{",
"final",
"int",
"[",
"]",
"offsets",
"=",
"new",
"int",
"[",
"nodes",
... | Create the offset array for the given nodes. The offsets are calculated
using the arity of the stored operations.
@param nodes the flattened tree nodes
@return the offset array for the given nodes | [
"Create",
"the",
"offset",
"array",
"for",
"the",
"given",
"nodes",
".",
"The",
"offsets",
"are",
"calculated",
"using",
"the",
"arity",
"of",
"the",
"stored",
"operations",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java#L449-L462 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/math/base.java | base.divide | public static void divide(final double[] values, final double divisor) {
for (int i = values.length; --i >= 0;) {
values[i] /= divisor;
}
} | java | public static void divide(final double[] values, final double divisor) {
for (int i = values.length; --i >= 0;) {
values[i] /= divisor;
}
} | [
"public",
"static",
"void",
"divide",
"(",
"final",
"double",
"[",
"]",
"values",
",",
"final",
"double",
"divisor",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"values",
".",
"length",
";",
"--",
"i",
">=",
"0",
";",
")",
"{",
"values",
"[",
"i",
"]"... | Component wise division of the given double array.
@param values the double values to divide.
@param divisor the divisor.
@throws NullPointerException if the given double array is {@code null}. | [
"Component",
"wise",
"division",
"of",
"the",
"given",
"double",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/math/base.java#L71-L75 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/math/base.java | base.pow | public static long pow(final long b, final long e) {
long base = b;
long exp = e;
long result = 1;
while (exp != 0) {
if ((exp & 1) != 0) {
result *= base;
}
exp >>>= 1;
base *= base;
}
return result;
} | java | public static long pow(final long b, final long e) {
long base = b;
long exp = e;
long result = 1;
while (exp != 0) {
if ((exp & 1) != 0) {
result *= base;
}
exp >>>= 1;
base *= base;
}
return result;
} | [
"public",
"static",
"long",
"pow",
"(",
"final",
"long",
"b",
",",
"final",
"long",
"e",
")",
"{",
"long",
"base",
"=",
"b",
";",
"long",
"exp",
"=",
"e",
";",
"long",
"result",
"=",
"1",
";",
"while",
"(",
"exp",
"!=",
"0",
")",
"{",
"if",
"... | Binary exponentiation algorithm.
@param b the base number.
@param e the exponent.
@return {@code b^e}. | [
"Binary",
"exponentiation",
"algorithm",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/math/base.java#L84-L98 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/TruncationSelector.java | TruncationSelector.select | @Override
public ISeq<Phenotype<G, C>> select(
final Seq<Phenotype<G, C>> population,
final int count,
final Optimize opt
) {
requireNonNull(population, "Population");
requireNonNull(opt, "Optimization");
if (count < 0) {
throw new IllegalArgumentException(format(
"Selection count must be greater o... | java | @Override
public ISeq<Phenotype<G, C>> select(
final Seq<Phenotype<G, C>> population,
final int count,
final Optimize opt
) {
requireNonNull(population, "Population");
requireNonNull(opt, "Optimization");
if (count < 0) {
throw new IllegalArgumentException(format(
"Selection count must be greater o... | [
"@",
"Override",
"public",
"ISeq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"select",
"(",
"final",
"Seq",
"<",
"Phenotype",
"<",
"G",
",",
"C",
">",
">",
"population",
",",
"final",
"int",
"count",
",",
"final",
"Optimize",
"opt",
")",
"{",... | This method sorts the population in descending order while calculating
the selection probabilities. If the selection size is greater the the
population size, the whole population is duplicated until the desired
sample size is reached.
@throws NullPointerException if the {@code population} or {@code opt} is
{@code null... | [
"This",
"method",
"sorts",
"the",
"population",
"in",
"descending",
"order",
"while",
"calculating",
"the",
"selection",
"probabilities",
".",
"If",
"the",
"selection",
"size",
"is",
"greater",
"the",
"the",
"population",
"size",
"the",
"whole",
"population",
"i... | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/TruncationSelector.java#L92-L127 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/internal/util/Concurrency.java | Concurrency.with | public static Concurrency with(final Executor executor) {
if (executor instanceof ForkJoinPool) {
return new ForkJoinPoolConcurrency((ForkJoinPool)executor);
} else if (executor instanceof ExecutorService) {
return new ExecutorServiceConcurrency((ExecutorService)executor);
} else if (executor == SERIAL_EXEC... | java | public static Concurrency with(final Executor executor) {
if (executor instanceof ForkJoinPool) {
return new ForkJoinPoolConcurrency((ForkJoinPool)executor);
} else if (executor instanceof ExecutorService) {
return new ExecutorServiceConcurrency((ExecutorService)executor);
} else if (executor == SERIAL_EXEC... | [
"public",
"static",
"Concurrency",
"with",
"(",
"final",
"Executor",
"executor",
")",
"{",
"if",
"(",
"executor",
"instanceof",
"ForkJoinPool",
")",
"{",
"return",
"new",
"ForkJoinPoolConcurrency",
"(",
"(",
"ForkJoinPool",
")",
"executor",
")",
";",
"}",
"els... | Return an new Concurrency object from the given executor.
@param executor the underlying Executor
@return a new Concurrency object | [
"Return",
"an",
"new",
"Concurrency",
"object",
"from",
"the",
"given",
"executor",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/internal/util/Concurrency.java#L73-L83 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java | EvolutionResult.getGenotypes | public ISeq<Genotype<G>> getGenotypes() {
return _population.stream()
.map(Phenotype::getGenotype)
.collect(ISeq.toISeq());
} | java | public ISeq<Genotype<G>> getGenotypes() {
return _population.stream()
.map(Phenotype::getGenotype)
.collect(ISeq.toISeq());
} | [
"public",
"ISeq",
"<",
"Genotype",
"<",
"G",
">",
">",
"getGenotypes",
"(",
")",
"{",
"return",
"_population",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Phenotype",
"::",
"getGenotype",
")",
".",
"collect",
"(",
"ISeq",
".",
"toISeq",
"(",
")",
")",... | Return the current list of genotypes of this evolution result.
@since 3.9
@return the list of genotypes of this evolution result. | [
"Return",
"the",
"current",
"list",
"of",
"genotypes",
"of",
"this",
"evolution",
"result",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L146-L150 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java | EvolutionResult.toBestEvolutionResult | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, EvolutionResult<G, C>>
toBestEvolutionResult() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().withTotalGenerat... | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, EvolutionResult<G, C>>
toBestEvolutionResult() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().withTotalGenerat... | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Collector",
"<",
"EvolutionResult",
"<",
"G",
",",
"C",
">",
",",
"?",
",",
"EvolutionResult",
"<",
"G",... | Return a collector which collects the best result of an evolution stream.
<pre>{@code
final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...;
final EvolutionResult<EnumGene<Point>, Double> result = Engine.builder(tsm)
.optimize(Optimize.MINIMUM).build()
.stream()
.limit(100)
.collect(EvolutionResult.toBestEvolu... | [
"Return",
"a",
"collector",
"which",
"collects",
"the",
"best",
"result",
"of",
"an",
"evolution",
"stream",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L355-L366 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java | EvolutionResult.toBestPhenotype | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, Phenotype<G, C>>
toBestPhenotype() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().getBestPhenotype()
: nul... | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, Phenotype<G, C>>
toBestPhenotype() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().getBestPhenotype()
: nul... | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Collector",
"<",
"EvolutionResult",
"<",
"G",
",",
"C",
">",
",",
"?",
",",
"Phenotype",
"<",
"G",
","... | Return a collector which collects the best phenotype of an evolution
stream.
<pre>{@code
final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...;
final Phenotype<EnumGene<Point>, Double> result = Engine.builder(tsm)
.optimize(Optimize.MINIMUM).build()
.stream()
.limit(100)
.collect(EvolutionResult.toBestPhenotyp... | [
"Return",
"a",
"collector",
"which",
"collects",
"the",
"best",
"phenotype",
"of",
"an",
"evolution",
"stream",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L389-L400 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java | EvolutionResult.toBestGenotype | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, Genotype<G>>
toBestGenotype() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().getBestPhenotype() != null
?... | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
Collector<EvolutionResult<G, C>, ?, Genotype<G>>
toBestGenotype() {
return Collector.of(
MinMax::<EvolutionResult<G, C>>of,
MinMax::accept,
MinMax::combine,
mm -> mm.getMax() != null
? mm.getMax().getBestPhenotype() != null
?... | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"Collector",
"<",
"EvolutionResult",
"<",
"G",
",",
"C",
">",
",",
"?",
",",
"Genotype",
"<",
"G",
">",... | Return a collector which collects the best genotype of an evolution
stream.
<pre>{@code
final Problem<ISeq<Point>, EnumGene<Point>, Double> tsm = ...;
final Genotype<EnumGene<Point>> result = Engine.builder(tsm)
.optimize(Optimize.MINIMUM).build()
.stream()
.limit(100)
.collect(EvolutionResult.toBestGenotype());
}</pr... | [
"Return",
"a",
"collector",
"which",
"collects",
"the",
"best",
"genotype",
"of",
"an",
"evolution",
"stream",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L423-L436 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java | EvolutionResult.toUniquePopulation | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
UnaryOperator<EvolutionResult<G, C>> toUniquePopulation(final int maxRetries) {
return result -> {
final Factory<Genotype<G>> factory = result
.getPopulation().get(0)
.getGenotype();
final UnaryOperator<EvolutionResult<G, C>> unifie... | java | public static <G extends Gene<?, G>, C extends Comparable<? super C>>
UnaryOperator<EvolutionResult<G, C>> toUniquePopulation(final int maxRetries) {
return result -> {
final Factory<Genotype<G>> factory = result
.getPopulation().get(0)
.getGenotype();
final UnaryOperator<EvolutionResult<G, C>> unifie... | [
"public",
"static",
"<",
"G",
"extends",
"Gene",
"<",
"?",
",",
"G",
">",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"UnaryOperator",
"<",
"EvolutionResult",
"<",
"G",
",",
"C",
">",
">",
"toUniquePopulation",
"(",
"final",
... | Return a mapping function, which removes duplicate individuals from the
population and replaces it with newly created one by the existing
genotype factory.
<pre>{@code
final Problem<Double, DoubleGene, Integer> problem = ...;
final Engine<DoubleGene, Integer> engine = Engine.builder(problem)
.mapping(EvolutionResult.t... | [
"Return",
"a",
"mapping",
"function",
"which",
"removes",
"duplicate",
"individuals",
"from",
"the",
"population",
"and",
"replaces",
"it",
"with",
"newly",
"created",
"one",
"by",
"the",
"existing",
"genotype",
"factory",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/engine/EvolutionResult.java#L643-L655 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/SingleNodeCrossover.java | SingleNodeCrossover.swap | static <A> int swap(final TreeNode<A> that, final TreeNode<A> other) {
assert that != null;
assert other != null;
final Random random = RandomRegistry.getRandom();
final ISeq<TreeNode<A>> seq1 = that.breadthFirstStream()
.collect(ISeq.toISeq());
final ISeq<TreeNode<A>> seq2 = other.breadthFirstStream()
... | java | static <A> int swap(final TreeNode<A> that, final TreeNode<A> other) {
assert that != null;
assert other != null;
final Random random = RandomRegistry.getRandom();
final ISeq<TreeNode<A>> seq1 = that.breadthFirstStream()
.collect(ISeq.toISeq());
final ISeq<TreeNode<A>> seq2 = other.breadthFirstStream()
... | [
"static",
"<",
"A",
">",
"int",
"swap",
"(",
"final",
"TreeNode",
"<",
"A",
">",
"that",
",",
"final",
"TreeNode",
"<",
"A",
">",
"other",
")",
"{",
"assert",
"that",
"!=",
"null",
";",
"assert",
"other",
"!=",
"null",
";",
"final",
"Random",
"rand... | The static method makes it easier to test. | [
"The",
"static",
"method",
"makes",
"it",
"easier",
"to",
"test",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/SingleNodeCrossover.java#L94-L126 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.sortAndRevert | static double[] sortAndRevert(final double[] array) {
final int[] indexes = sort(array);
// Copy the elements in reversed order.
final double[] result = new double[array.length];
for (int i = 0; i < result.length; ++i) {
result[indexes[result.length - 1 - i]] = array[indexes[i]];
}
return result;
} | java | static double[] sortAndRevert(final double[] array) {
final int[] indexes = sort(array);
// Copy the elements in reversed order.
final double[] result = new double[array.length];
for (int i = 0; i < result.length; ++i) {
result[indexes[result.length - 1 - i]] = array[indexes[i]];
}
return result;
} | [
"static",
"double",
"[",
"]",
"sortAndRevert",
"(",
"final",
"double",
"[",
"]",
"array",
")",
"{",
"final",
"int",
"[",
"]",
"indexes",
"=",
"sort",
"(",
"array",
")",
";",
"// Copy the elements in reversed order.",
"final",
"double",
"[",
"]",
"result",
... | Package private for testing. | [
"Package",
"private",
"for",
"testing",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L159-L169 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.checkAndCorrect | private static void checkAndCorrect(final double[] probabilities) {
boolean ok = true;
for (int i = probabilities.length; --i >= 0 && ok;) {
ok = Double.isFinite(probabilities[i]);
}
if (!ok) {
final double value = 1.0/probabilities.length;
for (int i = probabilities.length; --i >= 0;) {
probabili... | java | private static void checkAndCorrect(final double[] probabilities) {
boolean ok = true;
for (int i = probabilities.length; --i >= 0 && ok;) {
ok = Double.isFinite(probabilities[i]);
}
if (!ok) {
final double value = 1.0/probabilities.length;
for (int i = probabilities.length; --i >= 0;) {
probabili... | [
"private",
"static",
"void",
"checkAndCorrect",
"(",
"final",
"double",
"[",
"]",
"probabilities",
")",
"{",
"boolean",
"ok",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"probabilities",
".",
"length",
";",
"--",
"i",
">=",
"0",
"&&",
"ok",
";",
"... | Checks if the given probability values are finite. If not, all values are
set to the same probability.
@param probabilities the probabilities to check. | [
"Checks",
"if",
"the",
"given",
"probability",
"values",
"are",
"finite",
".",
"If",
"not",
"all",
"values",
"are",
"set",
"to",
"the",
"same",
"probability",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L202-L214 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.sum2one | static boolean sum2one(final double[] probabilities) {
final double sum = probabilities.length > 0
? DoubleAdder.sum(probabilities)
: 1.0;
return abs(ulpDistance(sum, 1.0)) < MAX_ULP_DISTANCE;
} | java | static boolean sum2one(final double[] probabilities) {
final double sum = probabilities.length > 0
? DoubleAdder.sum(probabilities)
: 1.0;
return abs(ulpDistance(sum, 1.0)) < MAX_ULP_DISTANCE;
} | [
"static",
"boolean",
"sum2one",
"(",
"final",
"double",
"[",
"]",
"probabilities",
")",
"{",
"final",
"double",
"sum",
"=",
"probabilities",
".",
"length",
">",
"0",
"?",
"DoubleAdder",
".",
"sum",
"(",
"probabilities",
")",
":",
"1.0",
";",
"return",
"a... | Check if the given probabilities sum to one.
@param probabilities the probabilities to check.
@return {@code true} if the sum of the probabilities are within the error
range, {@code false} otherwise. | [
"Check",
"if",
"the",
"given",
"probabilities",
"sum",
"to",
"one",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L223-L228 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.indexOfBinary | static int indexOfBinary(final double[] incr, final double v) {
int imin = 0;
int imax = incr.length;
int index = -1;
while (imax > imin && index == -1) {
final int imid = (imin + imax) >>> 1;
if (imid == 0 || (incr[imid] >= v && incr[imid - 1] < v)) {
index = imid;
} else if (incr[imid] <= v) {
... | java | static int indexOfBinary(final double[] incr, final double v) {
int imin = 0;
int imax = incr.length;
int index = -1;
while (imax > imin && index == -1) {
final int imid = (imin + imax) >>> 1;
if (imid == 0 || (incr[imid] >= v && incr[imid - 1] < v)) {
index = imid;
} else if (incr[imid] <= v) {
... | [
"static",
"int",
"indexOfBinary",
"(",
"final",
"double",
"[",
"]",
"incr",
",",
"final",
"double",
"v",
")",
"{",
"int",
"imin",
"=",
"0",
";",
"int",
"imax",
"=",
"incr",
".",
"length",
";",
"int",
"index",
"=",
"-",
"1",
";",
"while",
"(",
"im... | Perform a binary-search on the summed probability array. | [
"Perform",
"a",
"binary",
"-",
"search",
"on",
"the",
"summed",
"probability",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L243-L261 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.indexOfSerial | static int indexOfSerial(final double[] incr, final double v) {
int index = -1;
for (int i = 0; i < incr.length && index == -1; ++i) {
if (incr[i] >= v) {
index = i;
}
}
return index;
} | java | static int indexOfSerial(final double[] incr, final double v) {
int index = -1;
for (int i = 0; i < incr.length && index == -1; ++i) {
if (incr[i] >= v) {
index = i;
}
}
return index;
} | [
"static",
"int",
"indexOfSerial",
"(",
"final",
"double",
"[",
"]",
"incr",
",",
"final",
"double",
"v",
")",
"{",
"int",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"incr",
".",
"length",
"&&",
"index",
"==",
... | Perform a serial-search on the summed probability array. | [
"Perform",
"a",
"serial",
"-",
"search",
"on",
"the",
"summed",
"probability",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L266-L275 | train |
jenetics/jenetics | jenetics/src/main/java/io/jenetics/ProbabilitySelector.java | ProbabilitySelector.incremental | static double[] incremental(final double[] values) {
final DoubleAdder adder = new DoubleAdder(values[0]);
for (int i = 1; i < values.length; ++i) {
values[i] = adder.add(values[i]).doubleValue();
}
return values;
} | java | static double[] incremental(final double[] values) {
final DoubleAdder adder = new DoubleAdder(values[0]);
for (int i = 1; i < values.length; ++i) {
values[i] = adder.add(values[i]).doubleValue();
}
return values;
} | [
"static",
"double",
"[",
"]",
"incremental",
"(",
"final",
"double",
"[",
"]",
"values",
")",
"{",
"final",
"DoubleAdder",
"adder",
"=",
"new",
"DoubleAdder",
"(",
"values",
"[",
"0",
"]",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
... | In-place summation of the probability array. | [
"In",
"-",
"place",
"summation",
"of",
"the",
"probability",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics/src/main/java/io/jenetics/ProbabilitySelector.java#L280-L286 | train |
jenetics/jenetics | jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java | TreeNode.getChild | @Override
public TreeNode<T> getChild(final int index) {
if (_children == null) {
throw new ArrayIndexOutOfBoundsException(format(
"Child index is out of bounds: %s", index
));
}
return _children.get(index);
} | java | @Override
public TreeNode<T> getChild(final int index) {
if (_children == null) {
throw new ArrayIndexOutOfBoundsException(format(
"Child index is out of bounds: %s", index
));
}
return _children.get(index);
} | [
"@",
"Override",
"public",
"TreeNode",
"<",
"T",
">",
"getChild",
"(",
"final",
"int",
"index",
")",
"{",
"if",
"(",
"_children",
"==",
"null",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"format",
"(",
"\"Child index is out of bounds: %s\""... | Returns the child at the specified index in this node's child array.
@param index an index into this node's child array
@return the tree-node in this node's child array at the specified index
@throws ArrayIndexOutOfBoundsException if the {@code index} is out of
bounds | [
"Returns",
"the",
"child",
"at",
"the",
"specified",
"index",
"in",
"this",
"node",
"s",
"child",
"array",
"."
] | ee516770c65ef529b27deb283f071c85f344eff4 | https://github.com/jenetics/jenetics/blob/ee516770c65ef529b27deb283f071c85f344eff4/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java#L122-L131 | train |
jasminb/jsonapi-converter | src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java | ValidationUtils.ensureValidResource | public static void ensureValidResource(JsonNode resource) {
if (!resource.has(JSONAPISpecConstants.DATA) && !resource.has(JSONAPISpecConstants.META)) {
throw new InvalidJsonApiResourceException();
}
} | java | public static void ensureValidResource(JsonNode resource) {
if (!resource.has(JSONAPISpecConstants.DATA) && !resource.has(JSONAPISpecConstants.META)) {
throw new InvalidJsonApiResourceException();
}
} | [
"public",
"static",
"void",
"ensureValidResource",
"(",
"JsonNode",
"resource",
")",
"{",
"if",
"(",
"!",
"resource",
".",
"has",
"(",
"JSONAPISpecConstants",
".",
"DATA",
")",
"&&",
"!",
"resource",
".",
"has",
"(",
"JSONAPISpecConstants",
".",
"META",
")",... | Asserts that provided resource has required 'data' or 'meta' node.
@param resource resource | [
"Asserts",
"that",
"provided",
"resource",
"has",
"required",
"data",
"or",
"meta",
"node",
"."
] | 73b41c3b9274e70e62b3425071ca8afdc7bddaf6 | https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java#L25-L29 | train |
jasminb/jsonapi-converter | src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java | ValidationUtils.ensureNotError | public static void ensureNotError(ObjectMapper mapper, JsonNode resourceNode) {
if (resourceNode != null && resourceNode.hasNonNull(JSONAPISpecConstants.ERRORS)) {
try {
throw new ResourceParseException(ErrorUtils.parseError(mapper, resourceNode, Errors.class));
} catch (JsonProcessingException e) {
thr... | java | public static void ensureNotError(ObjectMapper mapper, JsonNode resourceNode) {
if (resourceNode != null && resourceNode.hasNonNull(JSONAPISpecConstants.ERRORS)) {
try {
throw new ResourceParseException(ErrorUtils.parseError(mapper, resourceNode, Errors.class));
} catch (JsonProcessingException e) {
thr... | [
"public",
"static",
"void",
"ensureNotError",
"(",
"ObjectMapper",
"mapper",
",",
"JsonNode",
"resourceNode",
")",
"{",
"if",
"(",
"resourceNode",
"!=",
"null",
"&&",
"resourceNode",
".",
"hasNonNull",
"(",
"JSONAPISpecConstants",
".",
"ERRORS",
")",
")",
"{",
... | Ensures that provided node does not hold 'errors' attribute.
@param resourceNode resource node
@throws ResourceParseException | [
"Ensures",
"that",
"provided",
"node",
"does",
"not",
"hold",
"errors",
"attribute",
"."
] | 73b41c3b9274e70e62b3425071ca8afdc7bddaf6 | https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ValidationUtils.java#L46-L54 | train |
jasminb/jsonapi-converter | src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java | JSONAPIDocument.createErrorDocument | @NotNull
public static JSONAPIDocument<?> createErrorDocument(Iterable<? extends Error> errors) {
JSONAPIDocument<?> result = new JSONAPIDocument();
result.errors = errors;
return result;
} | java | @NotNull
public static JSONAPIDocument<?> createErrorDocument(Iterable<? extends Error> errors) {
JSONAPIDocument<?> result = new JSONAPIDocument();
result.errors = errors;
return result;
} | [
"@",
"NotNull",
"public",
"static",
"JSONAPIDocument",
"<",
"?",
">",
"createErrorDocument",
"(",
"Iterable",
"<",
"?",
"extends",
"Error",
">",
"errors",
")",
"{",
"JSONAPIDocument",
"<",
"?",
">",
"result",
"=",
"new",
"JSONAPIDocument",
"(",
")",
";",
"... | Factory method for creating JSONAPIDocument that holds the Error object.
<p>
This method should be used in case error response is being built by the server side.
</p>
@param errors | [
"Factory",
"method",
"for",
"creating",
"JSONAPIDocument",
"that",
"holds",
"the",
"Error",
"object",
"."
] | 73b41c3b9274e70e62b3425071ca8afdc7bddaf6 | https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java#L114-L119 | train |
jasminb/jsonapi-converter | src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java | JSONAPIDocument.addLink | public void addLink(String linkName, Link link) {
if (links == null) {
links = new Links(new HashMap<String, Link>());
}
links.addLink(linkName, link);
} | java | public void addLink(String linkName, Link link) {
if (links == null) {
links = new Links(new HashMap<String, Link>());
}
links.addLink(linkName, link);
} | [
"public",
"void",
"addLink",
"(",
"String",
"linkName",
",",
"Link",
"link",
")",
"{",
"if",
"(",
"links",
"==",
"null",
")",
"{",
"links",
"=",
"new",
"Links",
"(",
"new",
"HashMap",
"<",
"String",
",",
"Link",
">",
"(",
")",
")",
";",
"}",
"lin... | Adds a named link.
@param linkName the named link to add
@param link the link to add | [
"Adds",
"a",
"named",
"link",
"."
] | 73b41c3b9274e70e62b3425071ca8afdc7bddaf6 | https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/JSONAPIDocument.java#L173-L178 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.