home › Forums › # Technical Support › Unhandled exception at 0x76212c1a in FuzzyLiteTest.exe
- This topic has 5 replies, 2 voices, and was last updated 9 years, 5 months ago by
Unknown.
-
AuthorPosts
-
April 18, 2014 at 17:08 #1047
Unknown
MemberHi everyone,
I compile fuzzylite with cMake for visual studio 2010 and a small test with codes from this website just failed with warning ‘Unhandled exception at 0x76212c1a in FuzzyLiteTest.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0030e718..’ at line “engine->process();” as in the program below. Would you please give me some suggestions on possible solutions? Thank you in advance.
My test code:
#include "stdafx.h" #include "fl/Headers.h" using namespace fl; int main(){ fl::Engine* engine = new fl::Engine; engine->setName("simple-dimmer"); fl::InputVariable* Ambient = new fl::InputVariable; Ambient->setEnabled(true); Ambient->setName("Ambient"); Ambient->setRange(0.000, 1.000); Ambient->addTerm(new fl::Triangle("DARK", 0.000, 0.250, 0.500)); Ambient->addTerm(new fl::Triangle("MEDIUM", 0.250, 0.500, 0.750)); Ambient->addTerm(new fl::Triangle("BRIGHT", 0.500, 0.750, 1.000)); engine->addInputVariable(Ambient); fl::OutputVariable* Power = new fl::OutputVariable; Power->setEnabled(true); Power->setName("Power"); Power->setRange(0.000, 1.000); Power->fuzzyOutput()->setAccumulation(new fl::Maximum); Power->setDefuzzifier(new fl::Centroid(200)); Power->setDefaultValue(fl::nan); Power->setLockValidOutput(false); Power->setLockOutputRange(false); Power->addTerm(new fl::Triangle("LOW", 0.000, 0.250, 0.500)); Power->addTerm(new fl::Triangle("MEDIUM", 0.250, 0.500, 0.750)); Power->addTerm(new fl::Triangle("HIGH", 0.500, 0.750, 1.000)); engine->addOutputVariable(Power); fl::RuleBlock* ruleBlock = new fl::RuleBlock; ruleBlock->setEnabled(true); ruleBlock->setName(""); ruleBlock->setConjunction(NULL); ruleBlock->setDisjunction(NULL); ruleBlock->setActivation(new fl::Minimum); ruleBlock->addRule(fl::Rule::parse("if Ambient is DARK then Power is HIGH", engine)); ruleBlock->addRule(fl::Rule::parse("if Ambient is MEDIUM then Power is MEDIUM", engine)); ruleBlock->addRule(fl::Rule::parse("if Ambient is BRIGHT then Power is LOW", engine)); engine->addRuleBlock(ruleBlock); std::string status; if (! engine->isReady(&status)) throw fl::Exception("Engine not ready. " "The following errors were encountered:\n" + status, FL_AT); fl::scalar light = Ambient->getMinimum() + 2 * (Ambient->range() / 50); Ambient->setInputValue(light); engine->process(); }
-
This topic was modified 9 years, 5 months ago by
Juan Rada-Vilela (admin).
April 18, 2014 at 18:50 #1048Juan Rada-Vilela (admin)
KeymasterHi icesand,
thank you for your email.
I have added a
FL_LOG(Power->defuzzify());
at the end to produce an output value from the application. I have revised your code and could not find any problem. I have compiled it under Linux using:g++ Test.cpp -Ifuzzylite -Lfuzzylite/bin -lfuzzylite
and I have found no issues either, the result from executing the application is an output value of 0.75.Could you try cleaning and building your application again? Have you modified fuzzylite’s source code? Perhaps try to compile from console such a small example just to ensure you have the right settings in VS.
I will try within minutes to compile in Windows to find out if there is something I am missing.
Cheers,
Juan
April 18, 2014 at 20:10 #1052Juan Rada-Vilela (admin)
KeymasterHi icesand,
I have managed to build your example from console in Windows by modifying the file
fuzzylite/CMakeLists.txt
line 106 toadd_executable(fl-bin Test.cpp)
such that building using cmake will producefuzzylite.exe
using the exact code of your engine. As expected, the library worked just fine and did not throw any exception. I am afraid your exception might caused be somewhere else, but it is not in fuzzylite 4.0. Let me know if I can help you further.Cheers,
Juan
April 18, 2014 at 22:02 #1053Unknown
MemberThank you for your hlep, and also for your great work on fuzzylite, which may be the most excellent tool in this field that I can find now. I would test my program with your methold again. Once the test is done, I would show you the results further and thank you again!
April 18, 2014 at 23:57 #1054Juan Rada-Vilela (admin)
KeymasterHi icesand,
thank you very much for your kind words :). I am glad it is helping you.
Cheers.
April 19, 2014 at 14:56 #1055Unknown
MemberHi Juan,
I have just test my program with your suggested method, finally it works as you said. Thank you very much for your help!
Matthew
-
This topic was modified 9 years, 5 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.