log cat I need to use fuzzylite in my app. For example input is service with poor good and excellent levels. Output is tip with low,medium,high levels . Here is the code. I got " unfortunately fuzzy has stopped error" . I am new to fuzzylite . Help me solve this issue
public class MainActivity extends Activity {
EditText inputEditText;
TextView output;
Double ser;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
inputEditText = (EditText) findViewById(R.id.service);
output = (TextView) findViewById(R.id.textView1);
ser = Double.parseDouble(inputEditText.getText().toString());
fuzzy();
}
public void fuzzy(){
Engine engine = new Engine();
engine.setName("simple-dimmer");
InputVariable service= new InputVariable();
service.setName("service");
service.setRange(0.000, 1.000);
service.addTerm(new Triangle("poor", 0.000, 0.250, 0.500));
service.addTerm(new Triangle("good", 0.250, 0.500, 0.750));
service.addTerm(new Triangle("excellent", 0.500, 0.750, 1.000));
engine.addInputVariable(service);
OutputVariable tip = new OutputVariable();
tip.setName("Power");
tip.setRange(0.000, 1.000);
tip.setDefaultValue(Double.NaN);
tip.addTerm(new Triangle("LOW", 0.000, 0.250, 0.500));
tip.addTerm(new Triangle("MEDIUM", 0.250, 0.500, 0.750));
tip.addTerm(new Triangle("HIGH", 0.500, 0.750, 1.000));
engine.addOutputVariable(tip);
RuleBlock ruleBlock = new RuleBlock();
ruleBlock.addRule(Rule.parse("if service is poor then tip is HIGH", engine));
ruleBlock.addRule(Rule.parse("if service is good then tip is MEDIUM", engine));
ruleBlock.addRule(Rule.parse("if service is excellent then tip is LOW", engine));
engine.addRuleBlock(ruleBlock);
engine.configure("", "", "Minimum", "Maximum", "Centroid");
engine.setInputValue("service",ser);
engine.process();
output.setText(String.format("0.3f", engine.getOutputValue("Output")));
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}