pcingola / jFuzzyLogic

The most complete fuzzy logic library in Java. The de-facto standard for research and industrial applications.
GNU Lesser General Public License v3.0
67 stars 33 forks source link

Can i do evaluate repeatedly? #7

Closed wuxu92 closed 8 years ago

wuxu92 commented 8 years ago

Hi, i have several groups of input, when i do setVariable and evalue like this:

// do one setVariables and evaluate first
// then repeatedly evaluate another group data
for (float[] ins : data) {
  fb = fis.getFunctionBlock("scaler");
  fis.setVariable("cpu", ins[0]);
  fis.setVariable("memory", ins[1]);
  fis.evaluate();

  // action is the output var
  Variable a = fb.getVariable("action");
  // a.getValue() here get the before evaluted value
}

the problem is the output value is always the the one before this evaluate...

is there anything others should i do before do a new evaluate?

wuxu92 commented 8 years ago

it seems i find the problem. that is when you do a loop evaluate as above, if no rule matched in this round, then the old value of defuzzify-var will be returned.

after i set a default value for the defuzzify block, it work as it should be.