00001 package edu.tum.cs.srl.bayesnets.bln.py; 00002 00003 import org.python.core.PyObject.ConversionException; 00004 00005 import edu.tum.cs.tools.JythonInterpreter; 00006 00007 public class State { 00008 JythonInterpreter jython; 00009 String varName; 00010 00011 public State(JythonInterpreter jython) { 00012 this.jython = jython; 00013 varName = "state"; 00014 jython.exec("%s = [None for i in range(len(mln.gndAtoms))]", varName); 00015 } 00016 00017 public void set(String gndAtom, boolean value) throws ConversionException { 00018 int idxGA = jython.evalInt("mln.gndAtoms['%s'].idx", gndAtom); 00019 jython.exec("%s[%d] = %s", varName, idxGA, value ? "True" : "False"); 00020 } 00021 00022 public boolean get(String gndAtom) throws ConversionException { 00023 return jython.evalBoolean("state[mln.gndAtoms['%s'].idx]", gndAtom); 00024 } 00025 }