int main() { int m=1; int l=1; double dt=0.01; pendulum1d_cost::N(0,0)=0.3; pendulum1d_cost::N(1,1)=0.3; pendulum1d_cost::Q=0.1; pendulum1d::Cost cost=pendulum1d_cost::cost; pendulum1d::DCost dcost=pendulum1d_cost::dcost; pendulum1d::Cost costN=pendulum1d_cost::costN; pendulum1d::DCost dcostN=pendulum1d_cost::dcostN; SAC<pendulum1d>::Functions func(cost, dcost, costN, dcostN); SAC<pendulum1d>::Params params; params.alpha=-20; params.beta=0.6; params.Tc=0.64; params.Tp=2.5; params.Ts=0.02; params.Tcal=0.01; params.kmax=6; pendulum1d::System sys(m,l); pendulum1d::State state0(-2,7); std::list<pendulum1d::Params> list_pars(1000, pendulum1d::State(0, 0)); std::list<Eigen::Matrix<double,1,1> > list_u; Sim<pendulum1d>::State_Sim sim(sys,dt); sim.init(state0); SAC<pendulum1d> sac(sys,dt); for(double t=0; t<30; t+=params.Ts) { sac.init(sim.get_state(), params, func, list_pars.begin(), list_pars.end(), &list_u); sac.sac_ctrl(list_u); sim.update(list_u.front()); list_u.pop_front(); sim.update(list_u.front()); list_u.pop_front(); } sim.save("/media/fantaosha/Documents/JHU/Summer 2015/results/result3.mat"); return 0; }
// Processes an event which drives a change in state. void processEvent (char event) { int ProcessedCorrectly = 0; currentState = peek (); printf ("Processing event: %c for state: %c \n", event, currentState); switch(currentState) { case STATE0: ProcessedCorrectly = state0 (event); break; case STATE1: ProcessedCorrectly = state1 (event); break; case STATE2: ProcessedCorrectly = state2 (event); break; case STATE3: ProcessedCorrectly = state3 (event); break; case STATE4: ProcessedCorrectly = state4 (event); break; case STATE5: ProcessedCorrectly = state5 (event); break; case STATE6: ProcessedCorrectly = state6 (event); break; case STATE7: ProcessedCorrectly = state7 (event); break; case STATE8: ProcessedCorrectly = state8 (event); break; case STATE9: ProcessedCorrectly = state9 (event); break; case STATEA: ProcessedCorrectly = state10 (event); break; case STATEB: ProcessedCorrectly = state11 (event); break; default: printf ("Unknown state %d for event %c \n", currentState, event); ProcessedCorrectly = 1; } if(ProcessedCorrectly == 1) { printf ("The Grammar Failed The Syntax Machine\n"); exit (0); } }
char* getType(char* in_token){ char type = ' '; char* output = " "; token = in_token; currChar = token[0]; currIndex = 0; type = state0(); switch (type){ case 'm': output = "malformed"; break; case 'n': output = "number"; break; case 'w': output = "word"; break; default: output = "idunno"; break; } //printf("\n%c - %s\n",type,output); return output; }