Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Gary Pamparà
@gpampara
def unboundedArchive: Gen[Archive[Double]] = for {
    u <- Archive.unbounded[Double](_<_) // Error:(13, 35) value map is not a member of cilib.Archive[Double] 
  } yield u
This gets translated to:
def unboundedArchive: Gen[Archive[Double]] =
    Archive.unbounded[Double](_<_).map(u => u)
So there are a few issues with the above:
Cian Steenkamp
@CianSteenkamp96
Okay.. I am Listening.. Watching.. Learning..
Gary Pamparà
@gpampara
1) Archive doesn't have a map function (whether it should or not is a different discussion)
2) You are telling the compiler that the code should result in a Gen[A], which it is not
So the error you get is due to (1) above
Cian Steenkamp
@CianSteenkamp96
Okay so now the question do we need map?
How do I know if we need map?
Gary Pamparà
@gpampara
That's not the issue at hand
even if we added a map function, it would still break compilation
so the question really should be: what are you wanting the code to do firstly, then we take it from there
Cian Steenkamp
@CianSteenkamp96
I want to specify some insertPolicy (condition) that if it holds true for the new solution (by being compared to the solutions already in the archive ) it is to be inserted
And that insertPolicy should be passed to our unbounded and bounded archives to be generated..
def insert(v: A): Archive[A] =
    this match {
      case Empty(b, c) => NonEmpty[A](List(v), b, c)
      case NonEmpty(l, b, c) =>
        b match {
          case Bounded(limit, deletePolicy) =>
            if (l.size < limit.value && l.forall(x => c(v, x))) // using it here
              NonEmpty[A](v :: l, b, c)
            else if (l.size >= limit.value && l.forall(x => c(v, x))){
              val selected = deletePolicy(l) 
              NonEmpty[A](v :: l.filterNot(x => x.equals(selected)), b, c) // using it here
            }
            else
              NonEmpty[A](l, b, c)
          case Unbounded() =>
            if(l.forall(x => c(v,x))) // using it here
              NonEmpty[A](v :: l, b, c)
            else
              NonEmpty[A](l, b, c)
        }
    }
Gary Pamparà
@gpampara
I'd jsut move the logic into a function then pass in 2 functions directly
so then you'd have 2 test for each case, one would test the failure case and the toerh the success
can't really do much more as the function is abstract, passed in by the user
Cian Steenkamp
@CianSteenkamp96
The logic of the insert function?
Gary Pamparà
@gpampara
logic of the test itself
Cian Steenkamp
@CianSteenkamp96
okay
Cian Steenkamp
@CianSteenkamp96
Hi @gpampara I have updated the tests after considering your advice..
Here is the links to the newest Archive and ArchiveTest..
The test passes :)
If you are happy with this I will make a PR, let me know?
Gary Pamparà
@gpampara
@CianSteenkamp96 cool. Thanks for the update - I'll have a look a bit later
Cian Steenkamp
@CianSteenkamp96
Thank you
Gary Pamparà
@gpampara
@CianSteenkamp96 https://gist.github.com/CianSteenkamp96/8629e2f5b18089880c6bbbcbf5404c06#file-archivetest_for_archive_v4-scala-L43 you're creating a NonEmptyList with n+1 elements, where you want n
NonEmptyList.nel(x, (x::xs).toIList) <- error here in the tail, or is x supposed to be duplicated in the NonEmptyList?
implementation looks much better
I'm not sure of the insert and delete policy functions should vbe separate, but I think you can slap together a PR
Cian Steenkamp
@CianSteenkamp96
Hi @gpampara thanks for the feedback
Wrt your comment about the error...
You are correct x should not be duplicated..
I changed it to..
NonEmptyList.nel(x, xs.toIList)
Cian Steenkamp
@CianSteenkamp96
I created a PR for Archive.scala and for ArchiveTest.scala :)
The insert and delete policies are separate since insert can be done based on dominance for example while deletion (from a full archive) can be based on crowding distance...
Not sure if that is what u were unsure about?
Gary Pamparà
@gpampara
Jsut an FYI: travis integration is currently broken
ADEKOYA ADEKUNLE ROTIMI
@adekunleadekoya
Bounded archive: do you mean an archive that puts a limit on the number of items that could be stored in the archive?
Gary Pamparà
@gpampara
Yes
ADEKOYA ADEKUNLE ROTIMI
@adekunleadekoya
Ok. Thanks.
Cian Steenkamp
@CianSteenkamp96
Hi @gpampara I replied with some comments on GitHub regarding the changes you requested to the pull request I made near the end of 2018. Sorry it took so long to discuss them. :)
Gary Pamparà
@gpampara
@CianSteenkamp96 don't worry about it. I'm a little disconnected until I get some of the thesis complete, but I'll reply in a detailed way as soon as I can
Cian Steenkamp
@CianSteenkamp96
Sure thing. Thanks @gpampara😊👍
Gary Pamparà
@gpampara
Just an update, due to all the changes in the Scala community at large, some changes will be comping to the project. These will (or at least should) be totally transparent changes with no user visible conflicts
This includes migrations to Scala 2.13
Gary Pamparà
@gpampara
A large website change is being prepared. Generally a good thing and includes a bunch more general info
Kyle Erwin
@KyleErwin
Awesome! Thanks Gary