All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bridge.sensor.service.WaitqueueEvaluator Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 4.0.267
Show newest version
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 WaitqueueEvaluator extends BasicEvaluator
{
	/** The wait queue cutoff len. */
	protected int max;
	
	/**
	 *  Create a new evaluator.
	 */
	public WaitqueueEvaluator(IExternalAccess component, MethodInfo mi) throws Exception
	{
		this(component, mi, 10);
	}
	
	/**
	 *  Create a new evaluator.
	 */
	public WaitqueueEvaluator(IExternalAccess component, MethodInfo mi, int max) throws Exception
	{
		super(component, WaitqueueProperty.NAME, mi);
		this.max = max;
	}
	
	/**
	 *  Calculate the value with 1 best and 0 worst.
	 *  Re-scales waiting times from [0,unlimited] to [1,0].
	 *  Uses linear scale with 0=1, 1=0.9, 10=0, 11=0
	 */
	public double calculateEvaluation(Integer value)
	{
		double ret = 1; // try out new services by ranking them first time with 1
		if(value!=null)
		{
			int val = value.intValue();
			if(val




© 2015 - 2024 Weber Informatics LLC | Privacy Policy