//==============================================================================
//	
//	Copyright (c) 2013-
//	Authors:
//	* Dave Parker <david.parker@comlab.ox.ac.uk> (University of Oxford)
//	* Mateusz Ujma <mateusz.ujma@cs.ox.ac.uk> (University of Oxford)
//	
//------------------------------------------------------------------------------
//	
//	This file is part of PRISM.
//	
//	PRISM is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; either version 2 of the License, or
//	(at your option) any later version.
//	
//	PRISM is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//	
//	You should have received a copy of the GNU General Public License
//	along with PRISM; if not, write to the Free Software Foundation,
//	Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//	
//==============================================================================

package heuristics.search;

/*
 * StateValue class represents the upper and lower value for each state and action. 
 * 
 */

public class StateValue {
	
	private double lowerBound = -1;
	private double upperBound = -1;
	private int action = ACTION_UNDEF;
	
	public static int ACTION_TERMINAL = -1;
	public static int ACTION_UNDEF = -2;
	
	public StateValue(double l, double u, int a) {
		lowerBound = l;
		upperBound = u;
		action = a;
	}
	
	public void setLowerBound(double l) {
		lowerBound = l;
	}
	
	public void setUpperBound(double u) {
		upperBound = u;
	}
	
	public void setAction(int a) {
		action = a;
	}
	
	public double getLowerBound() {
		return lowerBound;
	}
	
	public double getUpperBound() {
		return upperBound;
	}
	
	public int getAction() {
		return action;
	}
	
	public String toString() {
		return "Lower bound " + lowerBound + " Upper bound " + upperBound + " Diff " + (upperBound - lowerBound) + " using action " + action;
	}
	
	public boolean equals(Object o) {
		if(o == null) throw new NullPointerException();
		if(!(o instanceof StateValue)) return false;
		StateValue sv = (StateValue)o;
		boolean equals = true;
		equals = equals && (sv.lowerBound == lowerBound);
		equals = equals && (sv.upperBound == upperBound);
		equals = equals && sv.action == action;
		return equals;
	}
}
