/* 
 * Tactic is the legal property of its developers, whose names are too numerous 
 * to list here.  Please refer to the COPYRIGHT file distributed with this 
 * source distribution. 
 * 
 * This library is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version. 
 * 
 * This library 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 
 * Lesser General Public License for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library; if not, write to the Free Software 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 *
 * See README for more informations
 *
 * InferenceEngine.h
 *
 * ...
 * Date 02/03/06
 *
 */

#ifndef INFERENCE_ENGINE_H
#define INFERENCE_ENGINE_H

#include <stdio.h>
#include <string>
#include <vector>
#include "Operator.h"
#include "Implication.h"
#include "FuzzyRule.h"
#include "FuzzyValueName.h"

#define MIN_RESULT_VALUE 0.15f

class InferenceEngine{

private :

	std::vector<FuzzyValue> listResult;
	// The FuzzyValues result

	FuzzyValue result;
	// The FuzzyValue which is the best result for one inference 

	float* values;
	// Board to store the values of all the instance of a FuzzyValue

	fuzzyValueName* hash;
	// Board used to refer to a FuzzyValue

	int* length;
	// Number of instance of a FuzzyValue

	int vectorSize;
	// Length of listResult whiwh is the same as the vector given in parameter
	// of the fonction inferate

public :

	/**
	 * Constructor : Initialise the object with wrong parameters to detect
	 *               wrong uses of this object
	 */
	InferenceEngine(void);

	~InferenceEngine(void);

	/**
	 * inferate : This function evaluate all Rules 
	 * 
	 * @param theFuzzyRules : A list which contains all the FuzzyValues result
	 *  
	 * @return : void
	 * 
	 * @post : listResult -> ArrayList<FuzzyValue>
	 * 		   The FuzzyValues result are in this list
	 * 		   result -> FuzzyValue result
	 * 		   The best FuzzyValue is this attribute
	 *  
	 */
	void inferate (std::vector<FuzzyRule>* theFuzzyRules);

	/**
	 * getResult : Return the best result of the inference but you have 
	 *             to evaluate before
	 * 
	 * Detail : Before using this fonction, you have to evaluate.
	 *          It returns the best FuzzyValue.
	 * 
	 * @param void
	 *  
	 * @return FuzzyValue : The best result
	 *   
	 */
	FuzzyValue getResult();

	/**
	 * getAllResult : Return all results of the inference but you have 
	 *                to evaluate before
	 * 
	 * Description : Before using this fonction, you have to evaluate.
	 *               It returns all results in a vector of FuzzyValues.
	 * 
	 * @param void
	 *  
	 * @return std::vector<FuzzyValue> : All the results
	 *   
	 * @pre : You have to use evaluate once before using this fonction
	 * 
	 */
	std::vector<FuzzyValue> getAllResult();

	/**
	 * toString : Give a representation in String of the result of the 
	 *            inferance 
	 * 
	 * Return the list of the FuzzyValues result and the best result 
	 * 
	 * @param void
	 *  
	 * @return std::string
	 *   
	 * @pre : You have to evaluate once before using this fonction
	 * 
	 */
	std::string toString();

};

#endif
