Skip to content

syntax problem? #336

Description

@davidenitti

Dear,
I am trying to implement a probabilistic version of the Wumpus world, but I have this error:

Exception in thread "main" java.lang.ClassCastException: java.util.ArrayList cannot be cast to blog.common.numerical.MatrixLib
at blog.model.BuiltInFunctions$25.getValue(BuiltInFunctions.java:1053)
at blog.model.FixedFunction.getValueInInterpretation(FixedFunction.java:193)
at blog.model.FixedFunction.getValueInContext(FixedFunction.java:231)
at blog.model.FuncAppTerm.evaluate(FuncAppTerm.java:156)
at blog.model.FuncAppTerm.evaluate(FuncAppTerm.java:144)
at blog.model.FuncAppTerm.evaluate(FuncAppTerm.java:144)
at blog.model.EqualityFormula.evaluate(EqualityFormula.java:75)
at blog.model.CaseSpec.evaluate(CaseSpec.java:55)
at blog.model.CaseSpec.evaluate(CaseSpec.java:63)
at blog.model.CaseSpec.evaluate(CaseSpec.java:63)
at blog.model.DependencyModel.getDistrib(DependencyModel.java:151)
at blog.model.DependencyModel.getDistribWithBinding(DependencyModel.java:140)
at blog.bn.RandFuncAppVar.getDistrib(RandFuncAppVar.java:117)
at blog.sample.ClassicInstantiatingEvalContext.instantiate(ClassicInstantiatingEvalContext.java:154)
at blog.sample.ClassicInstantiatingEvalContext.getOrComputeValue(ClassicInstantiatingEvalContext.java:116)
at blog.sample.ParentRecEvalContext.getValue(ParentRecEvalContext.java:75)
at blog.bn.VarWithDistrib.ensureDetAndSupported(VarWithDistrib.java:129)
at blog.BLOGUtil.ensureDetAndSupported(BLOGUtil.java:34)
at blog.BLOGUtil.ensureDetAndSupported(BLOGUtil.java:44)
at blog.engine.Particle.answer(Particle.java:84)
at blog.engine.ParticleFilter.takeEvidenceAndAnswerQuery(ParticleFilter.java:174)
at blog.engine.ParticleFilter.answerQueries(ParticleFilter.java:127)
at blog.Main.run(Main.java:220)
at blog.Main.main(Main.java:158)

the code is this:

type State;
distinct State Up, Down, Left, Right;

type Cell;
distinct Cell free, wall;


fixed State action(Timestep t) =
 if t==@0 then
 Up
 else if t==@1
 then Up;

random Cell Maze(Integer x,Integer y,Timestep t) ~
  if t == @0 then
    Categorical({free -> 0.6, wall -> 0.4}) 
  else Maze(x,y,prev(t))
;


random RealMatrix Agent(Timestep t) ~
  if t == @0 then
    Categorical({[0;0]-> 1})
    else
    if action(t) == Up then
        if Maze(toInt(Agent(prev(t))[0][0]),toInt(Agent(prev(t))[0][1]+1),prev(t))==free then
            Categorical({ [Agent(prev(t))[0][0];Agent(prev(t))[0][1]+1] -> 0.9, Agent(prev(t)) -> 0.1} )
        else
            Agent(prev(t))
    else 
            Agent(prev(t))
;

query Agent(@1);

I think the error is related to the line:

if Maze(toInt(Agent(prev(t))[0][0]),toInt(Agent(prev(t))[0][1]+1),prev(t))==free then

that is I need to check if the maze cell above the agent position is free. is there any error in this?
thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions