本文整理汇总了Java中net.sourceforge.jFuzzyLogic.FIS类的典型用法代码示例。如果您正苦于以下问题:Java FIS类的具体用法?Java FIS怎么用?Java FIS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FIS类属于net.sourceforge.jFuzzyLogic包,在下文中一共展示了FIS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public static void main(String[] args) {
// Load from 'FCL' file
String fileName = "fcl/Blob.fcl";
FIS fis = FIS.load(fileName, true);
if (fis == null) {
System.err.println("Can't load file: '" + fileName + "'");
System.exit(1);
}
// Get default function block
FunctionBlock fb = fis.getFunctionBlock(null);
JFuzzyChart.get().chart(fb);
int [] lcom = {26,27,27,28,60,320,26,39}; // 25,40
int [] nom = {17,17,18,19,17,21,27,22}; // 14.5,22
int [] noa = {9,9,10,10,17,10,13,13}; // 8.5,13
JFuzzyChart.get().chart(fb);
for (int i = 0; i< lcom.length;i++){
fb.setVariable("lack_of_cohesion_in_methods", lcom[i]);
fb.setVariable("number_of_methods", nom[i]);
fb.setVariable("number_of_attributes", noa[i]);
fb.evaluate();
JFuzzyChart.get().chart(fb.getVariable("res"),fb.getVariable("res").getDefuzzifier(),true);
System.out.println("Res ("+lcom[i]+","+nom[i]+","+noa[i]+"): " + fb.getVariable("res").getValue());
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:27,代码来源:FuzzyTest.java
示例2: main
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.out.println("Begin TestTipperString");
String fcl = "FUNCTION_BLOCK tipper // Block definition (there may be more than one block per file)\n" + //
"\n" + //
"VAR_INPUT // Define input variables\n" + //
" service : REAL;\n" + //
" food : REAL;\n" + //
"END_VAR\n" + //
"\n" + //
"VAR_OUTPUT // Define output variable\n" + //
" tip : REAL;\n" + //
"END_VAR\n" + //
"\n" + //
"FUZZIFY service // Fuzzify input variable 'service': {'poor', 'good' , 'excellent'}\n" + //
" TERM poor := (0, 1) (4, 0) ; \n" + //
" TERM good := (1, 0) (4,1) (6,1) (9,0);\n" + //
" TERM excellent := (6, 0) (9, 1);\n" + //
"END_FUZZIFY\n" + //
"\n" + //
"FUZZIFY food // Fuzzify input variable 'food': { 'rancid', 'delicious' }\n" + //
" TERM rancid := (0, 1) (1, 1) (3,0) ;\n" + //
" TERM delicious := (7,0) (9,1);\n" + //
"END_FUZZIFY\n" + //
"\n" + //
"DEFUZZIFY tip // Defzzzify output variable 'tip' : {'cheap', 'average', 'generous' }\n" + //
" TERM cheap := (0,0) (5,1) (10,0);\n" + //
" TERM average := (10,0) (15,1) (20,0);\n" + //
" TERM generous := (20,0) (25,1) (30,0);\n" + //
" METHOD : COG; // Use 'Center Of Gravity' defuzzification method\n" + //
" DEFAULT := 0; // Default value is 0 (if no rule activates defuzzifier)\n" + //
"END_DEFUZZIFY\n" + //
"\n" + //
"RULEBLOCK No1\n" + //
" ACCU : MAX; // Use 'max' accumulation method\n" + //
" AND : MIN; // Use 'min' for 'and' (also implicit use 'max' for 'or' to fulfill DeMorgan's Law)\n" + //
" ACT : MIN; // Use 'min' activation method\n" + //
"\n" + //
" RULE 1 : IF service IS poor OR food is rancid THEN tip IS cheap;\n" + //
" RULE 2 : IF service IS good THEN tip IS average; \n" + //
" RULE 3 : IF service IS excellent AND food IS delicious THEN tip is generous;\n" + //
"END_RULEBLOCK\n" + //
"\n" + //
"END_FUNCTION_BLOCK\n";
FIS fis = FIS.createFromString(fcl, true);
FunctionBlock functionBlock = fis.getFunctionBlock("tipper");
JFuzzyChart.get().chart(functionBlock);
// Set inputs
functionBlock.setVariable("service", 3);
functionBlock.setVariable("food", 7);
// Evaluate fuzzy set
functionBlock.evaluate();
// Show output variable's chart
Variable tip = functionBlock.getVariable("tip");
JFuzzyChart.get().chart(tip, tip.getDefuzzifier(), true);
// Print ruleSet
System.out.println(functionBlock);
System.out.println("End TestTipperString");
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:66,代码来源:TestTipperString.java
示例3: testToString
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
/**
* Test method generating a string and parsing it
*/
@Test
public void testToString() {
Gpr.debug("Test");
// Load system
String fileName = "tests/tipper.fcl";
FIS fis = FIS.load(fileName, true);
// Parse FCL code generated by fis.toString()
FIS fis2;
try {
fis2 = FIS.createFromString(fis.toString(), false);
} catch (RecognitionException e) {
throw new RuntimeException("Could not parse FCL code generated by fis.toString(). This should never happen!!!");
}
// Compare both fis (should be identical)
boolean ok = fis.toString().equals(fis2.toString());
if (verbose) System.out.println("Are both fis equal?: " + ok);
if (!ok) throw new RuntimeException("FCL code for both fis is not the same.");
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:25,代码来源:TestCaseTipper.java
示例4: createTxtFile
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void createTxtFile() {
// Load from 'FCL' file
String fileName = "tests/tipper.fcl";
FIS fis = FIS.load(fileName, true);
// Show ruleset
FunctionBlock functionBlock = fis.getFunctionBlock(null);
// Set inputs
for (double service = 0; service <= 10; service += 1.0)
for (double food = 0; food <= 10; food += 1.0) {
// Set inputs
functionBlock.setVariable("service", service);
functionBlock.setVariable("food", food);
// Evaluate
functionBlock.evaluate();
// Get output
double tip = functionBlock.getVariable("tip").getValue();
// Show
System.out.println(service + "\t" + food + "\t" + tip);
}
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:26,代码来源:TestCaseTipper.java
示例5: checkMembershipFunction
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
/**
* Test method for membership function
*/
public void checkMembershipFunction(String title, FIS fis, String membershipFunctionFile) {
Gpr.debug("Test");
int mem[][] = loadMembershipFile(membershipFunctionFile);
if (verbose) System.out.println(fis);
FunctionBlock fb = fis.getFunctionBlock(null);
for (int ind = 1; ind < mem.length; ind++) {
double value = int100ToDouble(mem[ind][0]);
fb.setVariable("inVar", value);
int poor = doubleToInt100(fb.getVariable("inVar").getMembership("poor"));
int good = doubleToInt100(fb.getVariable("inVar").getMembership("good"));
int excellent = doubleToInt100(fb.getVariable("inVar").getMembership("excellent"));
if (poor != mem[ind][1]) fail("Membership function " + title + ", poor(" + value + ") should be " + int100ToDouble(mem[ind][1]) + ", but it is " + int100ToDouble(poor));
if (good != mem[ind][2]) fail("Membership function " + title + ", good(" + value + ") should be " + int100ToDouble(mem[ind][2]) + ", but it is " + int100ToDouble(good));
if (excellent != mem[ind][3]) fail("Membership function " + title + ", excellent(" + value + ") should be " + int100ToDouble(mem[ind][3]) + ", but it is " + int100ToDouble(excellent));
}
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:26,代码来源:TestCaseJfuzzy.java
示例6: testNAmembership
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
/**
* Test method a fuzzy system that showed NA values due to 'Triangle' membership function bug
* Bug report and FCL code by Shashankrao Wankhede
*/
@Test
public void testNAmembership() {
Gpr.debug("Test");
// FCL.debug = true;
FIS fis = FIS.load("./tests/junit_shashankrao.fcl", true);
if (verbose) System.out.println(fis);
// This set of values used to produce a 'NaN' output
double ra = 0.5;
double ad = 0.0;
fis.setVariable("ra", ra);
fis.setVariable("ad", ad);
fis.evaluate();
// Right output should be 0.5
double ta = fis.getVariable("ta").getValue();
if (Double.isNaN(ta) || Double.isInfinite(ta) || (Math.abs(ta - 0.5) > EPSILON)) fail("System's output should be 0.5, but it's " + ta + "\n" + fis.getVariable("ta"));
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:24,代码来源:TestCaseJfuzzy.java
示例7: test
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
@Test
public void test() {
Gpr.debug("Test");
// Prepare command line
String fileName = "tests/tipper.fcl";
String args[] = { "-noCharts", "-e", fileName, "8.5", "9" };
// Run
JFuzzyLogic jFuzzyLogic = new JFuzzyLogic(args);
jFuzzyLogic.run();
FIS fis = jFuzzyLogic.getFis();
// Check input variables
Assert.assertEquals(fis.getVariable("food").getValue(), 8.5, EPSILON);
Assert.assertEquals(fis.getVariable("service").getValue(), 9, EPSILON);
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:18,代码来源:TestCaseCommandLine.java
示例8: processFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public String processFuzzy(Context context, Double velocidade, Double rpm, Double acelerador) {
try {
AssetManager assetManager = context.getAssets();
InputStream is = assetManager.open(filename);
fis = FIS.load(is, true);
if (fis == null) {
Log.wtf(TAG, "Arquivo FDL não encontrado");
}
fis.setVariable("velocidade", velocidade);
fis.setVariable("rpm", rpm);
fis.setVariable("acelerador", acelerador);
fis.evaluate();
Variable consumo = fis.getVariable("consumo");
LinguisticTerm foundTerm = null;
Double foundMembership = 0.0;
List<LinguisticTerm> terms = consumo.linguisticTermsSorted();
for (LinguisticTerm term : terms) {
Double membership = consumo.getMembership(term.getTermName());
if (membership > foundMembership) {
foundTerm = term;
foundMembership = membership;
}
}
return foundTerm.getTermName();
} catch (IOException e) {
Log.e(TAG, "Não foi possível carregar o arquivo fcl");
return "";
}
}
开发者ID:Gaso-UFS,项目名称:gaso,代码行数:33,代码来源:FuzzyManager.java
示例9: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (cl:Class) WHERE cl.lack_of_cohesion_in_methods >" + high_lcom + " AND cl.number_of_methods > " + high_nom + " AND cl.number_of_attributes > " + high_noa + " RETURN cl.app_key as app_key,cl.lack_of_cohesion_in_methods as lack_of_cohesion_in_methods,cl.number_of_methods as number_of_methods, cl.number_of_attributes as number_of_attributes";
if(details){
query += ",cl.name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int lcom,noa,nom;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
lcom = (int) res.get("lack_of_cohesion_in_methods");
noa = (int) res.get("number_of_attributes");
nom = (int) res.get("number_of_methods");
if(lcom >= veryHigh_lcom && noa >= veryHigh_noa && nom >= veryHigh_nom){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("lack_of_cohesion_in_methods",lcom);
fb.setVariable("number_of_attributes",noa);
fb.setVariable("number_of_methods",nom);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_BLOB.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:41,代码来源:BLOBQuery.java
示例10: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (c:Class{is_broadcast_receiver:true})-[:CLASS_OWNS_METHOD]->(m:Method{name:'onReceive'}) WHERE m.number_of_instructions > "+high_noi+" AND m.cyclomatic_complexity>"+high_cc+" return m.app_key as app_key,m.cyclomatic_complexity as cyclomatic_complexity, m.number_of_instructions as number_of_instructions";
if(details){
query += ",m.full_name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int noi,cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("cyclomatic_complexity");
noi = (int) res.get("number_of_instructions");
if(cc >= veryHigh_cc && noi >= veryHigh_noi){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("cyclomatic_complexity",cc);
fb.setVariable("number_of_instructions",noi);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_HBR.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:39,代码来源:HeavyBroadcastReceiverQuery.java
示例11: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (cl:Class) WHERE HAS(cl.is_interface) AND cl.number_of_methods > " + high + " RETURN cl.app_key as app_key,cl.number_of_methods as number_of_methods";
if(details){
query += ",cl.name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("number_of_methods");
if(cc >= veryHigh){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("number_of_methods",cc);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_SAK.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:37,代码来源:SAKQuery.java
示例12: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (m:Method) WHERE m.number_of_instructions >" + high + " RETURN m.app_key as app_key,m.number_of_instructions as number_of_instructions";
if(details){
query += ",m.full_name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("number_of_instructions");
if(cc >= veryHigh){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("number_of_instructions",cc);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_LM.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:37,代码来源:LMQuery.java
示例13: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (c:Class{parent_name:'android.os.AsyncTask'})-[:CLASS_OWNS_METHOD]->(m:Method) WHERE (m.name='onPreExecute' OR m.name='onProgressUpdate' OR m.name='onPostExecute') AND m.number_of_instructions >"+high_noi+" AND m.cyclomatic_complexity > "+high_cc+" return m.app_key as app_key,m.cyclomatic_complexity as cyclomatic_complexity, m.number_of_instructions as number_of_instructions";
if(details){
query += ",m.full_name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int noi,cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("cyclomatic_complexity");
noi = (int) res.get("number_of_instructions");
if(cc >= veryHigh_cc && noi >= veryHigh_noi){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("cyclomatic_complexity",cc);
fb.setVariable("number_of_instructions",noi);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_HAS.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:39,代码来源:HeavyAsyncTaskStepsQuery.java
示例14: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (cl:Class) WHERE cl.class_complexity > " + high + " RETURN cl.app_key as app_key, cl.class_complexity as class_complexity";
if(details){
query += ",cl.name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("class_complexity");
if(cc >= veryHigh){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("class_complexity",cc);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_CC.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:37,代码来源:CCQuery.java
示例15: executeFuzzy
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void executeFuzzy(boolean details) throws CypherException, IOException {
Result result;
try (Transaction ignored = graphDatabaseService.beginTx()) {
String query = "MATCH (c:Class{is_service:true})-[:CLASS_OWNS_METHOD]->(m:Method{name:'onStartCommand'}) WHERE m.number_of_instructions > "+high_noi+" AND m.cyclomatic_complexity>"+high_cc+" return m.app_key as app_key,m.cyclomatic_complexity as cyclomatic_complexity, m.number_of_instructions as number_of_instructions";
if(details){
query += ",m.full_name as full_name";
}
result = graphDatabaseService.execute(query);
List<String> columns = new ArrayList<>(result.columns());
columns.add("fuzzy_value");
int noi,cc;
List<Map> fuzzyResult = new ArrayList<>();
File fcf = new File(fclFile);
//We look if the file is in a directory otherwise we look inside the jar
FIS fis;
if(fcf.exists() && !fcf.isDirectory()){
fis = FIS.load(fclFile, false);
}else{
fis = FIS.load(getClass().getResourceAsStream(fclFile),false);
}
FunctionBlock fb = fis.getFunctionBlock(null);
while(result.hasNext()){
HashMap res = new HashMap(result.next());
cc = (int) res.get("cyclomatic_complexity");
noi = (int) res.get("number_of_instructions");
if(cc >= veryHigh_cc && noi >= veryHigh_noi){
res.put("fuzzy_value", 1);
}else {
fb.setVariable("cyclomatic_complexity",cc);
fb.setVariable("number_of_instructions",noi);
fb.evaluate();
res.put("fuzzy_value", fb.getVariable("res").getValue());
}
fuzzyResult.add(res);
}
queryEngine.resultToCSV(fuzzyResult,columns,"_HSS.csv");
}
}
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:39,代码来源:HeavyServiceStartQuery.java
示例16: FuzzyLinguisticVariable
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
protected FuzzyLinguisticVariable(final String fclBlockName) throws PECodingException {
try (final InputStream fclSchema = PEFileUtils.getResourceStream(FuzzyLinguisticVariable.class, FCL_SCHEMA_FILE_NAME)) {
this.ai = FIS.load(fclSchema, false).getFunctionBlock(fclBlockName);
if (this.ai == null) {
throw new PECodingException("Could not load the Fuzzy Control Language (FCL) specification from '" + FCL_SCHEMA_FILE_NAME + "'");
}
} catch (final IOException | PEException e) {
logger.error(e.getMessage(), e);
throw new PECodingException(e);
}
}
开发者ID:Tesora,项目名称:tesora-dve-pub,代码行数:12,代码来源:FuzzyLinguisticVariable.java
示例17: main
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Load from 'FCL' file
String fileName = "fcl/tipper.fcl";
FIS fis = FIS.load(fileName, true);
if (fis == null) { // Error while loading?
System.err.println("Can't load file: '" + fileName + "'");
return;
}
// Show ruleset
FunctionBlock functionBlock = fis.getFunctionBlock(null);
JFuzzyChart.get().chart(functionBlock);
// Set inputs
functionBlock.setVariable("service", 3);
functionBlock.setVariable("food", 7);
// Evaluate
functionBlock.evaluate();
// Show output variable's chart
Variable tip = functionBlock.getVariable("tip");
JFuzzyChart.get().chart(tip, tip.getDefuzzifier(), true);
Gpr.debug("poor[service]: " + functionBlock.getVariable("service").getMembership("poor"));
// Print ruleSet
System.out.println(functionBlock);
System.out.println("TIP:" + functionBlock.getVariable("tip").getValue());
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:30,代码来源:TestTipper.java
示例18: animateFis
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
/**
* Show animation
* @param fis
* @throws Exception
*/
static void animateFis(FIS fis) throws Exception {
if (JFuzzyChart.UseMockClass) {
Gpr.debug("Using mock class");
return; // Nothing done
}
// Create a plot
JDialogFis jdf = new JDialogFis(fis, 800, 600);
// Set different values for 'food' and 'service'. Evaluate the system and show variables
// for( double service = 0.0, food = 1; service <= 10; service += 0.1 ) {
for (double service = 0.0, food = 1; service <= 10; service += 0.1) {
food = service;
// Evaluate system using these parameters
fis.getVariable("service").setValue(service);
fis.getVariable("food").setValue(food);
fis.evaluate();
// Print result & update plot
System.out.println(String.format("Service: %2.2f\tfood:%2.2f\t=> tip: %2.2f %%", service, food, fis.getVariable("tip").getValue()));
jdf.repaint();
// Small delay
Thread.sleep(100);
}
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:33,代码来源:TestTipperJava.java
示例19: initFisDebugPanel
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
void initFisDebugPanel() {
// Create a plot
if (fisPanel != null) {
System.out.println(" Remove existing fis panel");
fuzzyLayout.getTabPanel().remove(fisPanel);
}
FIS fis = fuzzyController.getFis();
List<Variable> list = fuzzyController.getVariables();
fisPanel = new DemoPanelFis(fuzzyController.getVariables(),
list.size(), 1);
fuzzyLayout.getTabPanel().add("Graphs", fisPanel);
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:13,代码来源:FuzzyDemo.java
示例20: reload
import net.sourceforge.jFuzzyLogic.FIS; //导入依赖的package包/类
public void reload(String str) {
FIS newfis;
try {
newfis = FIS.createFromString(str, true);
fis = newfis;
fisString = str;
// functionBlock = fis.getFunctionBlock(null);
init();
} catch(RecognitionException ex) {
Logger.getLogger(FuzzyController.class.getName()).log(Level.SEVERE, null, ex);
}
}
开发者ID:pcingola,项目名称:jFuzzyLogic,代码行数:14,代码来源:FuzzyController.java
注:本文中的net.sourceforge.jFuzzyLogic.FIS类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论