home Forums # Technical Support Android function for get result…

Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2590
    Unknown
    Member

    I am new from fuzzy logic..I need make function for get fuzzy output result.

    I have 4 inputs

    color_1(RBG or HEX color)
    color_2(RBG or HEX color)
    color_3(RBG or HEX color)

    I have existing defined out put for each result
    if output A if color is color_1 and color_3
    if output B if color is color_2 and color_3
    if output C if color is color_1 and color_3

    I need pass each input to fuzzy function and get results.

    public String fuzzyLogicEx(String color_1,String color_2,String color_3) {

        Engine engine = new Engine();
        engine.setName("SnakeDetection");
        engine.setDescription("");
    

    //how to set inputs???

    OutputVariable mSteer = new OutputVariable();
    mSteer.setName(“snake”);
    mSteer.setDescription(“”);
    mSteer.setEnabled(true);
    mSteer.setRange(0.000, 1.000);
    mSteer.setLockValueInRange(false);
    mSteer.setAggregation(new Maximum());
    mSteer.setDefuzzifier(new Centroid(100));
    mSteer.setDefaultValue(Double.NaN);
    mSteer.setLockPreviousValue(false);
    mSteer.addTerm(new Ramp(“cobra”,1));

        engine.addOutputVariable(mSteer);
    
        RuleBlock mamdani = new RuleBlock();
        mamdani.setName("mamdani");
        mamdani.setDescription("");
        mamdani.setEnabled(true);
        mamdani.setConjunction(null);
        mamdani.setDisjunction(null);
        mamdani.setImplication(new AlgebraicProduct());
        mamdani.setActivation(new General());
        mamdani.addRule(Rule.parse("if color is color_1 and color_3", engine));
        mamdani.addRule(Rule.parse("if obstacle is right then mSteer is left", engine));
    
       OutputVariable outputVariable = new OutputVariable();
        engine.process();
        System.out.println("Answer is " + outputVariable.getValue())
    

    return outputVariable.getValue();
    }

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.