本文整理汇总了Java中org.nlogo.api.Argument类的典型用法代码示例。如果您正苦于以下问题:Java Argument类的具体用法?Java Argument怎么用?Java Argument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Argument类属于org.nlogo.api包,在下文中一共展示了Argument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the lower
* envelope parameters.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A new lower envelope.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
LogoListBuilder endAux = new LogoListBuilder();
LogoListBuilder end = new LogoListBuilder();
List<double[]> result;
// Build the both piecewise linear sets.
PointSet a = new PiecewiseLinearSet(
SupportFunctions.checkListFormat(arg0[0].getList()), true,
"uno", SupportFunctions.universe(arg0[0].getList()));
PointSet b = new PiecewiseLinearSet(
SupportFunctions.checkListFormat(arg0[1].getList()), true,
"otro", SupportFunctions.universe(arg0[1].getList()));
// Calculate the lower envelope
result = DegreeOfFulfillment.lowerEnvelope(a, b);
// Add the points of the lower envelope in the logolist
for (double[] point : result) {
endAux = new LogoListBuilder();
endAux.add(point[0]);
endAux.add(point[1]);
end.add(endAux.toLogoList());
}
return end.toLogoList();
}
示例2: report
import org.nlogo.api.Argument; //导入依赖的package包/类
@Override
/**
* This method respond to the call from Netlogo and returns the set.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A Fuzzy Set.
*/
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
// If the string is not in the map throw an exception
if (FuzzyLogic.getRegistry().containsKey(arg0[0].getString())) {
// Get the fuzzy set with the label given.
return FuzzyLogic.getRegistry().get(arg0[0].getString());
} else {
throw new ExtensionException("There is no Fuzzy Set with label: "
+ arg0[0].getString());
}
}
示例3: report
import org.nlogo.api.Argument; //导入依赖的package包/类
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
LogoList elementsD = arg0[0].getList();
LogoList point;
Double x;
LogoList uni = arg0[1].getList();
Double[] universe = new Double[]{(Double) uni.first(),(Double) uni.get(1)};
List<Double> numbersToEvaluate = new ArrayList<Double>();
//Iterate over the parameters and add to a list the first number(x) of each points
Iterator<Object> it = elementsD.javaIterator();
while (it.hasNext()) {
Object o = it.next();
point =(LogoList) o;
x = (Double) point.first();
double min = universe[0];
double max = universe[1];
//If not in the universe of the continuous set dont add it
if(x >= min && x <= max){
numbersToEvaluate.add((Double) point.first());
}
}
LogoListBuilder result = new LogoListBuilder();
result.addAll(numbersToEvaluate);
return result.toLogoList();
}
示例4: report
import org.nlogo.api.Argument; //导入依赖的package包/类
@Override
/**
* When the extension is loaded call this method.
*/
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
//Checks if the first argument is a FuzzySet.
if(!(arg0[0].get() instanceof FuzzySet)){
throw new ExtensionException("The first argument must be a fuzzySet");
}
FuzzySet fuzzySet = (FuzzySet) arg0[0].get();
Object obj = arg0[1].get();
//If the second argument is a fuzzySet call degreeOfFulfillment
//if its a Double call singleEvaluation
//if its a LogoList call multipleEvaluation
//if its any other class it throw a extension exception
if(obj instanceof FuzzySet){
return fuzzySet.evaluate((FuzzySet)obj);
}else if(obj instanceof Double){
return fuzzySet.evaluate((Double) obj);
}else if(obj instanceof LogoList){
return multipleEvaluation(fuzzySet,(LogoList) obj);
}else{
throw new ExtensionException("The second argument must be a fuzzySet, a Number or a List");
}
}
示例5: report
import org.nlogo.api.Argument; //导入依赖的package包/类
@Override
/**
* This method respond to the call from Netlogo and returns the and-interval.
*
* @param arg0
* Arguments from Netlogo call, in this case a 2 list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A list representing the and-universe.
*/
public Object report(Argument[] arg0, Context arg1) throws ExtensionException, LogoException {
LogoList universe1 = arg0[0].getList();
LogoList universe2 = arg0[1].getList();
double[] univ1 = new double[]{(Double) universe1.first(),(Double) universe1.get(1)};
double[] univ2 = new double[]{(Double) universe2.first(),(Double) universe2.get(1)};
double[] fin = DegreeOfFulfillment.andInterval(univ1, univ2);
LogoListBuilder log = new LogoListBuilder();
if(fin.length == 2){
log.add(fin[0]);
log.add(fin[1]);
}else{
throw new ExtensionException("Vacio");
}
return log.toLogoList();
}
示例6: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the powered
* fuzzy set.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
double exp = arg0[1].getDoubleValue();
// Checks the exponent is greater than 0.
if (exp < 0) {
throw new ExtensionException(
"The value of the number must be greater than 0");
}
FuzzySet f = (FuzzySet) arg0[0].get();
if (f.isContinuous()) {
return new PowerSet(f, exp, true, "continuous-power",
f.getUniverse());
} else {
return powerDiscrete((PointSet) f, exp);
}
}
示例7: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the label of the
* given fuzzy set.
*
* @param arg0
* Arguments from Netlogo call, in this case a fuzzy set.
* @param arg1
* Context of Netlogo when the call was done.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet f =(FuzzySet) arg0[0].get();
Map<String,FuzzySet> reg = FuzzyLogic.getRegistry();
if(reg.containsValue(f)){
for(Entry<String, FuzzySet> ent : reg.entrySet()){
if(ent.getValue() == f){
return ent.getKey();
}
}
}else{
throw new ExtensionException("The fuzzy set has not a label assigned");
}
return null;
}
示例8: perform
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and delete the label of the given fuzzy set.
*
* @param arg0
* Arguments from Netlogo call, in this case a fuzzy set.
* @param arg1
* Context of Netlogo when the call was done.
*/
@Override
public void perform(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet f = (FuzzySet) arg0[0].get();
String key;
Map<String,FuzzySet> reg = FuzzyLogic.getRegistry();
//If the registry contains the fuzzy set given
if(reg.containsValue(f)){
//Iterate over the entries
for(Entry<String,FuzzySet> entry : reg.entrySet()){
//If the fuzzy set is the same delete that mapping
if(f == entry.getValue()){
key = entry.getKey();
reg.remove(key);
break;
}
}
}else{
throw new ExtensionException("That fuzzy set has not label");
}
}
示例9: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the mean of the
* maximum values of a fuzzy set.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A number with the mean of maxima of a fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet f = (FuzzySet) arg0[0].get();
double[] universe = f.getUniverse();
// If universe empty
if (universe.length == 0) {
new ExtensionException(
"You have tried to compute the FOM of an empty set");
}
// If continuous but not piecewise
if (f.isContinuous() && !(f instanceof PiecewiseLinearSet)) {
return continuousMeOM(f);
} else {
// If piecewise linear
if (f instanceof PiecewiseLinearSet) {
return piecewiseMeOM((PointSet) f);
} else {
return discreteMeOM(f);
}
}
}
示例10: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the center of
* gravity of a fuzzy set.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A number with the center of gravity of a fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet f = (FuzzySet) arg0[0].get();
double[] universe = f.getUniverse();
// If universe empty
if (universe.length == 0) {
new ExtensionException(
"You have tried to compute the FOM of an empty set");
}
if (f.isContinuous()) {
// If continuous and piecewise linear
if (f instanceof PiecewiseLinearSet) {
return piecewiseCOG((PointSet) f);
} else {// If just continuous
return continuousCOG(f);
}
} else {// If discrete
return discreteCOG((PointSet) f);
}
}
示例11: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the prodded
* fuzzy set after applying the rules given.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet conseq = (FuzzySet) arg0[1].get();
// Checks the format and evaluate all the rules inside the list.
List<Double> evaluations = SupportRules.variadicRulesChecks(arg0[0]
.getList());
double max = Double.NEGATIVE_INFINITY;
for (double d : evaluations) {
// If one evaluation is Not a Number return an empty set.
if (d == Double.NaN) {
return new EmptySet();
}
// Look for the max evaluated value.
if (d > max) {
max = d;
}
}
Prod p = new Prod();
// Prod the fuzzy set with the maximum value found
return p.prodding(conseq, max);
}
示例12: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the truncated
* fuzzy set after applying the rule given.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
double eval = 0;
FuzzySet conseq = (FuzzySet) arg0[1].get();
// Checks the format of the list and evaluate the rule inside.
eval = SupportRules.simpleRulesChecks(arg0[0].getList());
// If not a number is evaluated, return an Empty set.
if (eval == Double.NaN) {
return new EmptySet();
} else {
Cut c = new Cut();
// Truncate the fuzzy set with evaluated value.
return c.cutting(conseq, eval);
}
}
示例13: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the truncated
* fuzzy set after applying the rules given.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet conseq = (FuzzySet) arg0[1].get();
// Checks the format and evaluates all the rules inside the list.
List<Double> evaluations = SupportRules.variadicRulesChecks(arg0[0]
.getList());
double min = Double.POSITIVE_INFINITY;
for (double d : evaluations) {
// If one of the evaluation result is not a number, return an empty
// set.
if (d == Double.NaN) {
return new EmptySet();
}
// Look for the minimum evaluated value.
if (d < min) {
min = d;
}
}
// Truncate the fuzzy set with the minimum value found.
Cut c = new Cut();
return c.cutting(conseq, min);
}
示例14: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the prodded
* fuzzy set after applying the rules given.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
FuzzySet conseq = (FuzzySet) arg0[1].get();
// Checks the format and evaluates all the rules inside the list.
List<Double> evaluations = SupportRules.variadicRulesChecks(arg0[0]
.getList());
double min = Double.POSITIVE_INFINITY;
for (double d : evaluations) {
// If one of the evaluation result is not a number, return an empty
// set.
if (d == Double.NaN) {
return new EmptySet();
}
// Look for the minimum
if (d < min) {
min = d;
}
}
// Prod the fuzzy set with the minimum value found.
Prod p = new Prod();
return p.prodding(conseq, min);
}
示例15: report
import org.nlogo.api.Argument; //导入依赖的package包/类
/**
* This method respond to the call from Netlogo and returns the prodded
* fuzzy set after applying the rule given.
*
* @param arg0
* Arguments from Netlogo call, in this case a list.
* @param arg1
* Context of Netlogo when the call was done.
* @return A fuzzy set.
*/
@Override
public Object report(Argument[] arg0, Context arg1)
throws ExtensionException, LogoException {
double eval = 0;
FuzzySet conseq = (FuzzySet) arg0[1].get();
// Checks the format of the list and evaluate the rule inside.
eval = SupportRules.simpleRulesChecks(arg0[0].getList());
// If Not a Number return an empty set.
if (eval == Double.NaN) {
return new EmptySet();
} else {
// Prod the fuzzy set with the evaluated number.
Prod p = new Prod();
return p.prodding(conseq, eval);
}
}