alvesoaj / eFLL

eFLL (Embedded Fuzzy Logic Library) is a standard library for Embedded Systems
MIT License
211 stars 91 forks source link

error when trying to declare 3 input into 1 and condition #39

Closed Dazzshiet closed 1 year ago

Dazzshiet commented 1 year ago

Help me when i try to compile the code it says "Compilation error: no matching function for call to 'FuzzyRuleAntecedent::joinWithAND(FuzzySet&, FuzzySet&, FuzzySet*&)"

`#include

// For scope, instantiate all objects you will need to access in loop() // It may be just one Fuzzy, but for demonstration, this sample will print // all FuzzySet pertinence

// Fuzzy Fuzzy *fuzzy = new Fuzzy();

// FuzzyInputHB FuzzySet veryslow = new FuzzySet(60, 70, 70, 80); FuzzySet slow = new FuzzySet(70, 80, 80, 90); FuzzySet fast = new FuzzySet(80, 90, 90, 100); FuzzySet veryfast = new FuzzySet(90, 100, 100, 110);

// FuzzyInputTemp FuzzySet verycold = new FuzzySet(32, 33, 33, 34); FuzzySet cold = new FuzzySet(33, 34, 34, 35); FuzzySet hot = new FuzzySet(34, 35, 35, 36); FuzzySet veryhot = new FuzzySet(35, 36 , 36, 37);

// FuzzyInputGSR FuzzySet verydry= new FuzzySet(0 , 1 , 1 , 2); FuzzySet dry = new FuzzySet(1 , 2 , 2, 3); FuzzySet moist = new FuzzySet(2 , 3, 3, 4); FuzzySet verymoist = new FuzzySet(4 , 5 , 5 , 7);

// Fuzzyoutput FuzzySet relax= new FuzzySet(0 , 12.5 , 12.5 , 25); FuzzySet tenang = new FuzzySet(25, 37.5, 37.5, 50); FuzzySet cemas = new FuzzySet(50, 62.5, 62.5 , 75); FuzzySet stress = new FuzzySet(75, 87.5 , 87.5, 100);

void setup() { // Set the Serial output Serial.begin(9600); // Set a random seed randomSeed(analogRead(0));

// Every setup must occur in the function setup()

// FuzzyInput FuzzyInput *Hb = new FuzzyInput(1);

Hb->addFuzzySet(veryslow); Hb->addFuzzySet(slow); Hb->addFuzzySet(fast); Hb->addFuzzySet(veryfast); fuzzy->addFuzzyInput(Hb);

// FuzzyInput FuzzyInput *Temp = new FuzzyInput(2);

Temp->addFuzzySet(verycold); Temp->addFuzzySet(cold); Temp->addFuzzySet(hot); Temp->addFuzzySet(veryhot); fuzzy->addFuzzyInput(Temp);

// FuzzyInput FuzzyInput *Gsr = new FuzzyInput(3);

Gsr->addFuzzySet(verydry); Gsr->addFuzzySet(dry); Gsr->addFuzzySet(moist); Gsr->addFuzzySet(verymoist); fuzzy->addFuzzyInput(Gsr);

// FuzzyOutput FuzzyOutput *Condition = new FuzzyOutput(1);

Condition->addFuzzySet(relax); Condition->addFuzzySet(tenang); Condition->addFuzzySet(cemas); Condition->addFuzzySet(stress); fuzzy->addFuzzyOutput(Condition);

FuzzyRuleAntecedent *IfHbVeryslowAndTempVeryhotGsrverydry= new FuzzyRuleAntecedent(); IfHbVeryslowAndTempVeryhotGsrverydry->joinWithAND(veryslow, veryhot, verydry );

FuzzyRuleConsequent *thenConditionrelax = new FuzzyRuleConsequent(); thenConditionrelax->addOutput(relax);

FuzzyRule *fuzzyRule1 = new FuzzyRule(1, IfHbVeryslowAndTempVeryhotGsrverydry, thenConditionrelax); fuzzy->addFuzzyRule(fuzzyRule1); void loop() { // get random entrances int input1 = random(60, 110); int input2 = random(32, 37); int input3 = random(1, 7);

Serial.println("\n\n\nEntrance: "); Serial.print("\t\t\denyut jantung: "); Serial.print(input1); Serial.print(", suhu tubuh: "); Serial.print(input2); Serial.print(", and kelembaban: "); Serial.println(input3);

fuzzy->setInput(1, input1); fuzzy->setInput(2, input2); fuzzy->setInput(3, input3);

fuzzy->fuzzify();

Serial.println("Input: "); Serial.print("\tHb: veryslow-> "); Serial.print(veryslow->getPertinence()); Serial.print("\tHb: slow-> "); Serial.print(slow->getPertinence()); Serial.print("\tHb: fast-> "); Serial.print(fast->getPertinence()); Serial.print("\tHb: veryfast-> "); Serial.print(veryfast->getPertinence());

Serial.println("Input2: "); Serial.print("\tTemp: veryhot-> "); Serial.print(veryhot->getPertinence()); Serial.print("\tTemp: hot-> "); Serial.print(hot->getPertinence()); Serial.print("\tTemp: cold-> "); Serial.print(cold->getPertinence()); Serial.print("\tTemp: verycold-> "); Serial.print(verycold->getPertinence());

Serial.println("Input3: "); Serial.print("\tGsr: verydry-> "); Serial.print(verydry->getPertinence()); Serial.print("\tGsr: dry-> "); Serial.print(dry->getPertinence()); Serial.print("\tGsr: moist-> "); Serial.print(moist->getPertinence()); Serial.print("\tGsr: verymoist-> "); Serial.print(verymoist->getPertinence());

float output1 = fuzzy->defuzzify(1);

Serial.println("Output: "); Serial.print("\tKondisi: Relax-> "); Serial.print(relax->getPertinence()); Serial.print(", Tenang-> "); Serial.print(tenang->getPertinence()); Serial.print(", Cemas-> "); Serial.println(cemas->getPertinence()); Serial.print(", Stress-> "); Serial.println(stress->getPertinence());

// wait 12 seconds delay(12000); }`

alvesoaj commented 1 year ago

Hey Diaz, I just caught it.

You are trying to join three objects, you should do that two by two see doc

First joining two, them join the third one with the first result

best,