Guest User

Untitled

a guest
Jul 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import cilib.exec._
  2. import scalaz._
  3. import Scalaz._
  4.  
  5. case class PrettyPrinter[S](progress: Progress[NonEmptyList[Entity[S, Double]]]) {
  6.  
  7. def algorithm: String =
  8. "Algorithm: " + progress.algorithm
  9.  
  10. def problem: String =
  11. "Problem: " + progress.problem
  12.  
  13. def env: String =
  14. "Environment: " + progress.env
  15.  
  16. def seed: String =
  17. "Seed Value: " + progress.seed
  18.  
  19. def iteration: String =
  20. "Iteration: " + progress.iteration
  21.  
  22. def data: String =
  23. progress.value.zipWithIndex.map(x => {
  24. "Entity " + (x._2 + 1) + "\n" +
  25. "Position: " + x._1.pos.pos.toList.mkString(", ") + "\n" +
  26. "Bounds: " + x._1.pos.boundary + "\n" +
  27. "Objective: " + { x._1.pos match {
  28. case Point(_, _) => "No Solution"
  29. case Solution(_, _, o) => o.toString
  30. }} + "\n"
  31. }).toList.mkString("\n")
  32.  
  33. def print: String =
  34. List(algorithm, problem, env, seed, iteration, data).mkString("\n")
  35.  
  36. }
  37.  
  38. /* Example output
  39.  
  40. Algorithm: gbestPSO
  41. Problem: spherical
  42. Environment: Unchanged
  43. Seed Value: 12
  44. Iteration: 1000
  45. Entity 1
  46. Position: -8.730969538820549E-37, -6.901927373365559E-39, 9.052529288449284E-38
  47. Bounds: NonEmpty[[-5.12, 5.12],[-5.12, 5.12],[-5.12, 5.12]]
  48. Objective: Single(Feasible(7.705407561314136E-73),List())
  49.  
  50. Entity 2
  51. Position: 8.861523679566886E-37, -2.6192883222213787E-37, 2.272751331731796E-39
  52. Bounds: NonEmpty[[-5.12, 5.12],[-5.12, 5.12],[-5.12, 5.12]]
  53. Objective: Single(Feasible(8.538778977831153E-73),List())
  54.  
  55. ...
  56. */
Add Comment
Please, Sign In to add comment