CSV Example#294
Conversation
| simulation(ackley, ackleyStream), | ||
| simulation(quadric, quadricStream), | ||
| simulation(spherical, sphericalStream) | ||
| ).flatten |
There was a problem hiding this comment.
Although flatten does make sense, I'd prefer us to use List.concat here to make the intention that little bit clearer
| case Infeasible(_, _) => Double.PositiveInfinity | ||
| case Adjusted(_, _) => Double.PositiveInfinity | ||
| } | ||
| case Multi(_) => Double.PositiveInfinity |
There was a problem hiding this comment.
I really want these cases hidden from the user in order to prevent people using the holes that scala allows to change this data. The Position is a very important structure for CIlib, so I would actually suggest that we allow this access only via a lens. The crux at the end of the day would be that the if the fitness is a feasible value, we get that otherwise we return the PositiveInfinity value.
This can be done with:
Lenses._singleFitness[Double].composePrism(Lenses._feasible)
which results in an Optional[Position[Double], Double]. The optic can then be used (via getOption) to get the value within an Option which we can then getOrElse(Double.PositiveInfinity) on.
val feasibleOptic = Lenses._singleFitness[Double].composePrism(Lenses._feasible)
val fitnessValues = collection.map(x => feasibleOptic.getOption(x).getOrElse(Double.PositiveInfinity))| import spire.implicits._ | ||
| import spire.math.Interval | ||
|
|
||
| object CSVExample extends SafeApp { |
There was a problem hiding this comment.
We should perhaps make this more generic (the name of the object). The reason being that the only difference between this example and the one that uses the parquet output is the sink used on line 135.
| swarm, | ||
| Runner.staticAlgorithm("LBestPSO", lbestIter), | ||
| stream, | ||
| onChange) |
There was a problem hiding this comment.
Perhaps remove some duplication?
List(
Runner.staticAlgorithm("GBestPSO", gbestIter),
Runner.staticAlgorithm("LBestPSO", lbestIter))
.map(alg => Runner.foldStep(env,
rng,
swarm,
alg,
stream,
onChange))|
Looks good otherwise 👍 |
The resulting optic is now a `Fold` and not an `Optional`
An example showcasing how a user could compare multiple algorithms across multiple benchmarks and output the results to some file format such as
csv. There are also step by step comments to guide the userthrough the example.