Beispiel #1
0
void testCensor(const char* source, int length, bool (*testFun)(const char*, int)) {
	if (!Filter::isInitialized()) {
		Filter::init(Filter::HIGH);
	}
	Time startTime = getCurrentTime();
	std::cout << "-- start --------------------------------------" << std::endl;
	std::cout << (testFun(source, length) ? "legal" : "illegal") << std::endl;
	Time endTime = getCurrentTime();
	g_totalSeconds += timeInterval(startTime, endTime);
	std::cout << "time costs: " << g_totalSeconds << " seconds" << std::endl;
	std::cout << "--- end -------------------------------------" << std::endl;
}
Beispiel #2
0
////
/// \brief GlFrame::render
/// Rendering function to be called at each frame
///
void GlFrame::render()
{
    m_timeSinceLastFrame = timeInterval(m_currentTime, Clock::now());
    m_currentTime = Clock::now();

    applyCameraTransformations();

    // Rendu des objets
    pushMatrix();
        //useShader("color");
        //g_Basis->draw();

        for(unsigned int i=0; i<m_systems.size(); i++){
            pushMatrix();
            //translate(i, 0, 0);
            m_systems[i]->draw();
            popMatrix();
        }

    popMatrix();
}
int main( ){

    USING_NAMESPACE_ACADO


    // Define a Right-Hand-Side:
    // -------------------------

    DifferentialState   x, y;

    DifferentialEquation f;

    f << dot(x) ==  y;
    f << dot(y) == -x;


    // Define an integrator:
    // ---------------------

    IntegratorRK45 integrator( f );
    integrator.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
	integrator.set( PRINT_INTEGRATOR_PROFILE, YES );
	
    // Define an initial value:
    // ------------------------
    double x_start[2] = { 0.0, 1.0 };
    Grid timeInterval( 0.0, 2.0*M_PI, 100 );

    integrator.freezeAll();
    integrator.integrate( timeInterval, x_start );


    // GET THE RESULTS
    // ---------------

    VariablesGrid differentialStates;
    integrator.getX( differentialStates );

    GnuplotWindow window;
        window.addSubplot( differentialStates(0) );
        window.addSubplot( differentialStates(1) );

    window.plot();


//     Vector seed(2);
// 
//     seed( 0 ) = 1.0;
//     seed( 1 ) = 0.0;
// 
//     integrator.setForwardSeed( 1, seed );
//     integrator.integrateSensitivities();
// 
//     VariablesGrid sens;
//     integrator.getForwardSensitivities( sens, 1 );
// 
//     GnuplotWindow window2;
//         window2.addSubplot( sens(0) );
//         window2.addSubplot( sens(1) );
//     window2.plot();


    return 0;
}
Beispiel #4
0
int main( ){


    // Define a Right-Hand-Side:
    // -------------------------
    DifferentialState x("", 4, 1), P("", 4, 4);
    Control           u("", 2, 1);

    IntermediateState rhs = cstrModel( x, u );

    DMatrix Q = zeros<double>(4,4);

    Q(0,0) = 0.2;
    Q(1,1) = 1.0;
    Q(2,2) = 0.5;
    Q(3,3) = 0.2;


    DMatrix R = zeros<double>(2,2);

    R(0,0) = 0.5;
    R(1,1) = 5e-7;

    DifferentialEquation f;
    f << dot(x) == rhs;
    f << dot(P) == getRiccatiODE( rhs, x, u, P, Q, R );



    // Define an integrator:
    // ---------------------

    IntegratorRK45 integrator( f );
    integrator.set( INTEGRATOR_PRINTLEVEL, MEDIUM );
	integrator.set( PRINT_INTEGRATOR_PROFILE, YES );
	
    // Define an initial value:
    // ------------------------
    //double x_ss[4] = { 2.14, 1.09, 114.2, 112.9 };
	double x_start[20] = { 1.0, 0.5, 100.0, 100.0, 1.0, 0.0, 0.0, 0.0,
                                                   0.0, 1.0, 0.0, 0.0,
                                                   0.0, 0.0, 1.0, 0.0,
                                                   0.0, 0.0, 0.0, 1.0 };

	double u_start[2] = { 14.19, -1113.5 };
//	double u_start[2] = { 10.00, -7000.0 };

	Grid timeInterval( 0.0, 5000.0, 100 );

    integrator.freezeAll();
    integrator.integrate( timeInterval, x_start, 0 ,0, u_start );


    // GET THE RESULTS
    // ---------------

    VariablesGrid differentialStates;
    integrator.getX( differentialStates );

	DVector PP = differentialStates.getLastVector();
	DMatrix PPP(4,4);
	for( int i=0; i<4; ++i )
		for( int j=0; j<4; ++j )
			PPP(i,j) = PP(4+i*4+j);
	PPP.print( "P1.txt","",PS_PLAIN );
//	PPP.printToFile( "P2.txt","",PS_PLAIN );

    GnuplotWindow window;
        window.addSubplot( differentialStates(0), "cA [mol/l]" );
        window.addSubplot( differentialStates(1), "cB [mol/l]" );
        window.addSubplot( differentialStates(2), "theta [C]" );
        window.addSubplot( differentialStates(3), "thetaK [C]" );

        window.addSubplot( differentialStates(4 ), "P11" );
        window.addSubplot( differentialStates(9 ), "P22" );
        window.addSubplot( differentialStates(14), "P33" );
        window.addSubplot( differentialStates(19), "P44" );
		
    window.plot();

    return 0;
}