package infosapient.hdg;
/*
* 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 java.rmi.server.ObjID;
/**
* Class FzyHdgNEAR raises <code> m[i]^1.75 </code>. (Less of an effect than CLOSE, but more than
* SLIGHTLY.)
* @author: Michael McConnell
*/
public class FzyHdgNEAR extends FzyHedge {
static final long serialVersionUID = 187192261404489914L;
public FzyHdgNEAR() { myID = new ObjID();}
public FzySet apply(FzySet aSet) {
double compare = 0.0d;
VECMAX = aSet.getMemberArray().length;
results = new double[VECMAX];
m = aSet.getMemberArray();
double domainLength = aSet.getHighDomain() - aSet.getLowDomain();
double interval = domainLength / (VECMAX-1);
int inxOfDomainForMaxMem = 0;
try {
double domainForMaxMem = aSet.domainForMembership(aSet.getMaxHeight());
inxOfDomainForMaxMem =
aSet.getIndexForDomain(domainForMaxMem);
double d_inx = (double) inxOfDomainForMaxMem;
for (int jnx = 0; jnx < VECMAX; jnx++) {
if (m[jnx] != 0.0) {
double d_jnx = (double) jnx;
double diff = d_jnx - d_inx;
double p1 = Math.abs(diff * interval);
double p2 = (1.0d / ( 1.0d + Math.pow(p1, NEAR_EXP)) * m[jnx]);
//System.out.println(" jnx = \t"+ jnx+"\t diff = "+diff+",\t part1 =\t "+p1+",\t part2 =\t "+p2);
results[jnx] = Math.max(results[jnx], p2);
}
}
aSet.setMembershipArray(results);
} catch (Exception fse) {
fse.printStackTrace();
}
return aSet;
}
public String getName() { return "near"; }
}