jadex.bridge.sensor.service.ExecutionTimeEvaluator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.sensor.service;
import jadex.bridge.IExternalAccess;
import jadex.bridge.nonfunctional.search.BasicEvaluator;
import jadex.commons.MethodInfo;
/**
* Execution time evaluator.
* Re-scales execution times from [0,unlimited] to [1,0].
*/
public class ExecutionTimeEvaluator extends BasicEvaluator
{
/**
* Create a new evaluator.
*/
public ExecutionTimeEvaluator(IExternalAccess component, MethodInfo mi) throws Exception
{
super(component, ExecutionTimeProperty.NAME, mi);
}
/**
* Create a new evaluator.
*/
public ExecutionTimeEvaluator(IExternalAccess component, MethodInfo mi, boolean required) throws Exception
{
super(component, ExecutionTimeProperty.NAME, mi, null, required);
}
/**
* Calculate the value with 1 best and 0 worst.
* Re-scales waiting times from [0,unlimited] to [1,0].
*/
public double calculateEvaluation(Long value)
{
double ret = 1; // try out new services
if(value!=null)
{
// Using a scaled e^(-ax) function with a=0.01 or similar to stretch the lowering
// double a = 0.01;
double a = 0.001;
ret = Math.exp(-value*a);
}
return ret;
}
}