00001 /* 00002 * Created on Oct 27, 2009 00003 * 00004 * TODO To change the template for this generated file go to 00005 * Window - Preferences - Java - Code Style - Code Templates 00006 */ 00007 package edu.tum.cs.srl.bayesnets.bln.coupling; 00008 00009 import edu.tum.cs.logic.GroundAtom; 00010 import edu.tum.cs.logic.GroundLiteral; 00011 import edu.tum.cs.logic.PossibleWorld; 00012 import edu.tum.cs.logic.WorldVariables; 00013 import edu.tum.cs.util.datastruct.ArraySlice; 00014 00015 public class BooleanVariable implements IVariableLogicCoupler { 00016 protected GroundAtom ga; 00017 00018 public BooleanVariable(GroundAtom ga) { 00019 this.ga = ga; 00020 } 00021 00022 public int getValue(PossibleWorld w) { 00023 return w.get(ga.index) ? 0 : 1; // True is first element 00024 } 00025 00026 public void setValue(PossibleWorld w, int domIdx) { 00027 w.set(ga.index, domIdx == 0); 00028 } 00029 00030 public GroundLiteral getGroundLiteral(int domIdx, WorldVariables worldVars) { 00031 return new GroundLiteral(domIdx == 0, ga); 00032 } 00033 00034 public Iterable<String> getOriginalParams() { 00035 return new ArraySlice<String>(ga.args, 0); 00036 } 00037 }