コード例 #1
0
    float DefuzzifyChaos()
    {
        float lTLP = (lawful.GetMin() + (lawful.GetMid() - lawful.GetMin()) * fuzzyLaw);
        float lTRP = (lawful.GetMax() + (lawful.GetMid() - lawful.GetMax()) * fuzzyLaw);

        float nTLP = (cNeutral.GetMin() + (cNeutral.GetMid() - cNeutral.GetMin()) * fuzzyCNeutral);
        float nTRP = (cNeutral.GetMax() + (cNeutral.GetMid() - cNeutral.GetMax()) * fuzzyCNeutral);

        float cTRP = (chaotic.GetMin() + (chaotic.GetMid() - chaotic.GetMin()) * fuzzyChaos);
        float cTLP = (chaotic.GetMax() + (chaotic.GetMid() - chaotic.GetMax()) * fuzzyChaos);


        float crispDefuz = 0;

        Trapezoid lawfulDefuz   = new Trapezoid(lawful.GetMin(), lTLP, lTRP, lawful.GetMax(), fuzzyNeutral);
        Trapezoid chaosDefuz    = new Trapezoid(chaotic.GetMin(), cTLP, cTRP, chaotic.GetMax(), fuzzyChaos);
        Trapezoid cNeutralDefuz = new Trapezoid(cNeutral.GetMin(), nTLP, nTRP, cNeutral.GetMax(), fuzzyCNeutral);

        float lRepValue;
        float nRepValue;
        float cRepValue;

        lRepValue = (lawfulDefuz.GetLMax() + lawfulDefuz.GetRMin()) / 2;
        nRepValue = (cNeutralDefuz.GetLMax() + cNeutralDefuz.GetRMin()) / 2;
        cRepValue = (chaosDefuz.GetLMax() + chaosDefuz.GetRMin()) / 2;

        float numerator   = (lRepValue * fuzzyLaw) + (nRepValue * fuzzyCNeutral) + (cRepValue * fuzzyChaos);
        float denominator = (fuzzyLaw + fuzzyCNeutral + fuzzyChaos);

        crispDefuz = numerator / denominator;
        return(crispDefuz);
    }
コード例 #2
0
    float DefuzzifyMorality()
    {
        float tLP        = (neutral.GetMin() + (neutral.GetMid() - neutral.GetMin()) * fuzzyNeutral);
        float tRP        = (neutral.GetMax() + (neutral.GetMid() - neutral.GetMax()) * fuzzyNeutral);
        float crispDefuz = 0;

        Trapezoid          defuzPeak = new Trapezoid(25, tLP, tRP, 75, fuzzyNeutral);
        LeftShoulderGraph  defuzL    = new LeftShoulderGraph(25, 50, fuzzyEvil);
        RightShoulderGraph defuzR    = new RightShoulderGraph(50, 75, fuzzyGood);

        float eRepValue;
        float nRepValue;
        float gRepValue;

        eRepValue = (defuzL.GetMin() + xMin) / 2;
        nRepValue = (defuzPeak.GetLMax() + defuzPeak.GetRMin()) / 2;
        gRepValue = (defuzR.GetMax() + xMax) / 2;

        float numerator   = (eRepValue * fuzzyEvil) + (nRepValue * fuzzyNeutral) + (gRepValue * fuzzyGood);
        float denominator = (fuzzyEvil + fuzzyGood + fuzzyNeutral);

        crispDefuz = numerator / denominator;
        return(crispDefuz);
    }