Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.github.ericmedvet.jgea.experimenter.builders.Plots Maven / Gradle / Ivy
/*-
* ========================LICENSE_START=================================
* jgea-experimenter
* %%
* Copyright (C) 2018 - 2023 Eric Medvet
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =========================LICENSE_END==================================
*/
package io.github.ericmedvet.jgea.experimenter.builders;
import io.github.ericmedvet.jgea.core.listener.NamedFunction;
import io.github.ericmedvet.jgea.core.listener.XYPlotTableBuilder;
import io.github.ericmedvet.jgea.core.solver.Individual;
import io.github.ericmedvet.jgea.core.solver.state.POSetPopulationState;
import io.github.ericmedvet.jnb.core.Param;
import java.util.Collection;
import java.util.List;
public class Plots {
private Plots() {}
public enum Sorting {
MIN,
MAX
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> dyPlot(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param("y") NamedFunction super POSetPopulationState, ? extends Number> yFunction,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, List.of(yFunction), width, height, minX, maxX, minY, maxY, true, true);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> elapsed(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param(value = "y", dNPM = "ea.nf.elapsed()")
NamedFunction super POSetPopulationState, ? extends Number> yFunction,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = 0) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, List.of(yFunction), width, height, minX, maxX, minY, maxY, true, true);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> fitness(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param(value = "collection", dNPM = "ea.nf.all()")
NamedFunction, Collection>>
collectionFunction,
@Param(value = "f", dNPM = "ea.nf.identity()") NamedFunction fFunction,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY,
@Param(value = "sort", dS = "min") Sorting sorting,
@Param(value = "s", dS = "%.2f") String s) {
NamedFunction, Collection> collFFunction =
NamedFunctions.each(
fFunction.of(NamedFunctions.fitness(NamedFunctions.identity(), s)),
collectionFunction,
"%s");
List, ? extends Number>> yFunctions =
switch (sorting) {
case MIN -> List.of(
NamedFunctions.min(collFFunction, s),
NamedFunctions.median(collFFunction, s),
NamedFunctions.max(collFFunction, s));
case MAX -> List.of(
NamedFunctions.max(collFFunction, s),
NamedFunctions.median(collFFunction, s),
NamedFunctions.min(collFFunction, s));
};
return new XYPlotTableBuilder<>(
xFunction, yFunctions, width, height, minX, maxX, minY, maxY, true, false);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> uniqueness(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param(
value = "ys",
dNPMs = {
"ea.nf.uniqueness(collection=ea.nf.each(map=ea.nf.genotype();collection=ea.nf.all()))",
"ea.nf.uniqueness(collection=ea.nf.each(map=ea.nf.solution();collection=ea.nf.all()))",
"ea.nf.uniqueness(collection=ea.nf.each(map=ea.nf.fitness();collection=ea.nf.all()))"
})
List, ? extends Number>> yFunctions,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = 0) double minY,
@Param(value = "maxY", dD = 1) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, yFunctions, width, height, minX, maxX, minY, maxY, true, false);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder xyPlot(
@Param("x") NamedFunction super E, ? extends Number> xFunction,
@Param("y") NamedFunction super E, ? extends Number> yFunction,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, List.of(yFunction), width, height, minX, maxX, minY, maxY, true, false);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder xysPlot(
@Param("x") NamedFunction super E, ? extends Number> xFunction,
@Param("ys") List> yFunctions,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, yFunctions, width, height, minX, maxX, minY, maxY, true, false);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> yPlot(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param("y") NamedFunction super POSetPopulationState, ? extends Number> yFunction,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, List.of(yFunction), width, height, minX, maxX, minY, maxY, true, false);
}
@SuppressWarnings("unused")
public static XYPlotTableBuilder> ysPlot(
@Param(value = "x", dNPM = "ea.nf.iterations()")
NamedFunction super POSetPopulationState, ? extends Number> xFunction,
@Param("ys")
List, ? extends Number>> yFunctions,
@Param(value = "w", dI = 600) int width,
@Param(value = "h", dI = 400) int height,
@Param(value = "minX", dD = Double.NEGATIVE_INFINITY) double minX,
@Param(value = "maxX", dD = Double.NEGATIVE_INFINITY) double maxX,
@Param(value = "minY", dD = Double.NEGATIVE_INFINITY) double minY,
@Param(value = "maxY", dD = Double.NEGATIVE_INFINITY) double maxY) {
return new XYPlotTableBuilder<>(
xFunction, yFunctions, width, height, minX, maxX, minY, maxY, true, false);
}
}