package infosapient.resolution;
/*
* Copyright (c) 2001, Workplace Performance Tools, All Rights Reserved.
*
* LICENSE TO USE THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE 0.5
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
* The license may be viewed at:
* http://www.opensource.org/licenses/cpl.html
*/
import infosapient.system.FzySet;
import infosapient.system.FzySystemException;
import java.rmi.server.ObjID;
/**
* Return the mean of domain(s) that are mapped to a membership value.
* If there is only one domain for a given membership,
* then that value is returned.
* @author: Michael McConnell
* @version $Revision: 1.1.1.1 $
*
*/
public class FzyResAVERAGE_MAXIMUM extends FzyResolutionMethod
{
static final long serialVersionUID = -4598275741783895312L;
public FzyResAVERAGE_MAXIMUM() {super();}
/**
* Return the mean of domain(s) that are mapped to a membership value.
* If there is only one domain for a given membership,
* then that value is returned.
* @param FzySet the FzySet to be defuzzified.
* @return double the average of the highest domain values(s).
* @exception FzySystemException thrown if no membership found that matches.
*/
public double resolveUsing(FzySet fset) {
double domainValue = Double.NaN;
try {
int indexForDefuzz = 0;
java.util.Vector plateaus = _findPlateau(fset);
if ((plateaus == null) || (plateaus.isEmpty())) throw new FzySystemException("No plateau found!!!");
PlateauLocation pLoc = (PlateauLocation) plateaus.elementAt(0);
indexForDefuzz =(int) ((double)((pLoc.start + pLoc.end))/2.0);
domainValue = fset.getDomain(indexForDefuzz);
} catch (FzySystemException fre) {
System.out.println(fre);
} finally {
return domainValue;
}
}
}