MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TrainThenTestApplication.cpp
Go to the documentation of this file.
1 
24 
25 namespace mic {
26 namespace application {
27 
28 
30 {
31  // Start from learning.
32  APP_STATE->setLearningModeOn();
33 }
34 
35 
37 
38  // Start from learning.
39  APP_STATE->setLearningModeOn();
40 
41  // Main application loop.
42  while (!APP_STATE->Quit()) {
43 
44  // If not paused.
45  if (!APP_STATE->isPaused()) {
46  // If single step mode - pause after the step.
47  if (APP_STATE->isSingleStepModeOn())
48  APP_STATE->pressPause();
49 
50  // Enter critical section - with the use of scoped lock from AppState!
52 
53  // Increment iteration number - at START!
54  iteration++;
55  // Perform single step and - if required - break the loop.
56  if (!performSingleStep())
57  break;
58 
59  } //: if! is paused & end of critical section
60 
61  // Sleep.
62  APP_SLEEP();
63  }//: while
64 }
65 
67  // If learning mode.
68  if (APP_STATE->isLearningModeOn()) {
69  // Perform learning - until there is something to learn.
70  if (!performLearningStep()) {
71  APP_STATE->setLearningModeOff();
72  }
73  } else {
74  // Perform testing - until there is something to test.
75  if (!performTestingStep())
76  return false;
77  }//: else
78 
79  return true;
80 }
81 
82 
83 
84 
85 } /* namespace application */
86 } /* namespace mic */
#define APP_SLEEP()
Macro which sleeps the application for a time specified by the sleep_interval variable stored in APP_...
Base class for all applications.
Definition: Application.hpp:38
#define APP_STATE
Macro returning application state instance.
#define APP_DATA_SYNCHRONIZATION_SCOPED_LOCK()
Macro creating a scoped lock with the use of data_synchronizaton_mutex stored by WindowManager.
unsigned long iteration
Iteration counter.
Definition: Application.hpp:72
Contains declaration of a base class for all train-then-test type applications.