Class TestGoal

java.lang.Object
nl.uu.cs.aplib.mainConcepts.Goal
eu.iv4xr.framework.mainConcepts.TestGoal

public class TestGoal extends Goal
A TestGoal is a Goal, but you can additionally specify a test oracle. When a TestGoal receives a proposal from a test-agent (through the method propose_(Object)), and if this proposal is judged as solving the goal, the method propose_(Object) will automatically pass the proposal to be inspected by the test-oracle.

A test-oracle expresses a test on the correctness of the proposal (not to be confused with the goal-predicate itself). E.g. the goal may only require that a certain object becomes accessible to the agent, whereas the oracle would test whether this object has the correct properties. A test-oracle is essentially a function f that will inspect a given proposal-object and returns a verdict.

Author:
Wish
  • Field Details

  • Constructor Details

    • TestGoal

      public TestGoal(String name)
      Create a blank test-goal with the specified name.
    • TestGoal

      public TestGoal(String name, TestAgent ta)
      Create a blank test-goal with the specified name, and link this goal to the given test agent.
  • Method Details

    • oracle_

      public TestGoal oracle_(TestAgent testagent, Function<Object,​ObservationEvent.VerdictEvent> oracle)
      Specify the test-oracle associated with for this TestGoal. Note that every TestGoal must have an oracle.
      Parameters:
      testagent - The test-agent to which this TestGoal will be associated to (the one that will work on this goal).
      oracle - The oracle predicate/function.
    • invariant

      public <Proposal> TestGoal invariant(TestAgent testagent, Function<Proposal,​ObservationEvent.VerdictEvent> oracle)
      Just another name for oracle(TestAgent,Function). It is used to specify the test-oracle associated with for this TestGoal. Note that every TestGoal must have an oracle. This method will also link this teat-goal to the given test-agent.
    • invariant

      public <Proposal> TestGoal invariant(Function<Proposal,​ObservationEvent.VerdictEvent> oracle)
      Just another name for oracle(TestAgent,Function). It is used to specify the test-oracle associated with for this TestGoal. Note that every TestGoal must have an oracle. This method assumes that this test-goal has been linked to some test-agent.
    • oracle

      public <Proposal> TestGoal oracle(TestAgent testagent, Function<Proposal,​ObservationEvent.VerdictEvent> oracle)
      Specify the test-oracle associated with for this TestGoal. Note that every TestGoal must have an oracle. This method will also link this teat-goal to the given test-agent.
      Parameters:
      testagent - The test-agent to which this TestGoal will be associated to (the one that will work on this goal).
      oracle - The oracle predicate/function.
    • oracle

      public <Proposal> TestGoal oracle(Function<Proposal,​ObservationEvent.VerdictEvent> oracle)
      Specify the test-oracle associated with for this TestGoal. Note that every TestGoal must have an oracle. Also note that a test-goal must be linked to a test-agent. This method assumes that this test-goal has been linked to one.
      Parameters:
      oracle - The oracle predicate/function.
    • propose_

      protected void propose_(Object proposal)
      We override Goal.propose_(Object) so that it now automatically check the oracle when the given proposal solves this Goal.
      Overrides:
      propose_ in class Goal
    • ftoSolve

      public <Proposal> TestGoal ftoSolve(Function<Proposal,​Double> predicateToSolve)
      Set the given function as a goal function. A proposal o is a solution if abs(goalfunction(o)) is a value less than epsilon (default is 0.005). The more general typing of the method's signature is for convenience, to allow you to explicitly specify the type of the goal's proposals domain at the point where this method is called, e.g. as in:
       Goal g = new Goal().ftoSolve((Integer x) -> x - 9999);
       
      The method returns this Goal itself so that it can be used in the Fluent Interface style.
      Overrides:
      ftoSolve in class Goal
    • toSolve

      public <Proposal> TestGoal toSolve(Predicate<Proposal> predicateToSolve)
      Set the predicate which would serve as the predicate to solve. The more general typing of the method's signature is for convenience, to allow you to explicitly specify the type of the goal's proposals domain at the point where this method is called, e.g. as in:
       Goal g = new Goal().toSolve((Integer x) -> x == 9999);
       
      The method returns this Goal itself so that it can be used in the Fluent Interface style.
      Overrides:
      toSolve in class Goal
    • withEpsilon

      public TestGoal withEpsilon(Double e)
      Set the value of eplison. The method returns this Goal itself so that it can be used in the Fluent Interface style.
      Overrides:
      withEpsilon in class Goal
    • withTactic

      public TestGoal withTactic(Tactic S)
      Set the strategy to that a solving agent can use to solve this goal. The method returns this Goal itself so that it can be used in the Fluent Interface style.
      Overrides:
      withTactic in class Goal