home › Forums › Feature Requests › Reading/Writing FIS files using FuzzyLite › Reply To: Reading/Writing FIS files using FuzzyLite
January 16, 2014 at 16:45
#872
Keymaster
What you require is not too hard and you do not need to build fuzzylite from source to achieve so.
Roughly, in SomeFile.cpp:
#include <fl/Headers.h>
int main(int argc, char** argv){
std::string fisEngine = readFromSomeFile("xxx.fis");
std::vector<std::vector<fl::scalar> > inputs = readFromSomeFileAndParse("xxx.dat");
fl::Engine* engine = FisImporter().fromString(fisEngine);
for (std::size_t i = 0 ; i < inputs.size(); ++i){
for (std::size_t x = 0 ; x < inputs.at(i).size(); ++x){
engine->getInputVariable(x)->setInputValue(inputs.at(i).at(x));
}
engine->process();
for (int i = 0 ; i < engine->numberOfOutputVariables(); ++i){
fl::scalar output = engine->getOutputVariable(i)->defuzzify();
writeToSomeFile(output + " ");
}
writeToSomeFile(output + "\n");
}
You have to implement yourself the read and write functions and fix some details.
g++ SomeFile.cpp -I/path/to/fuzzylite/fuzzylite -L/path/to/fuzzylite/fuzzylite/bin -lfuzzylite