예제 #1
0
int main()  
{  
    init();  
    initgraph(640, 480);   
    sol1();  
    sol4();  
    getch();  
    closegraph();  
    return 0;  
}  
예제 #2
0
double FixedPointStep(const DataStructure& Mesh, const sparse& Diff, const matrix& RHS, vector& x1, vector& x2, vector& x3, 
					  vector& x4, vector& x5, double coef)
{
	int Npts = Mesh.GetNverts();

	vector  theta1 = ConstructTheta(c1,x3),
			theta2 = ConstructTheta(c2,x3),
			theta3 = ConstructTheta(c3,x3),

		RHS1 = RHS[0],
		RHS2 = RHS[1],
		RHS3 = RHS[2] + kr * x1 * x2 + alfa * c3 * theta3 + delta * c1 * theta1 * x5 + beta * (1.0 - theta2) * c2 * x4,
		RHS4 = RHS[3] + (x3 - c3) * alfa * theta3,
		RHS5 = RHS[4] + gama * (x3 - c2) * theta2 * x4;
		
	sparse Op1 = Diff * Da, Op2 = Diff * Db, Op3 = Diff * Dc;

	vector v1 = coef + kr * x2,
	       v2 = coef + kr * x1,
	       v3 = coef + alfa * theta3 + delta * theta1 * x5 + beta * (1.0 - theta2) * x4;
 
	Op1.Diag(v1);
	Op2.Diag(v2);
	Op3.Diag(v3);

	vector sol1 = Op1(RHS1,x1),
	       sol2 = Op2(RHS2,x2),
	       sol3 = Op3(RHS3,x3),
	       sol4(Npts,.0),
	       sol5(Npts,.0),

	       Op4 = coef + gama * (x3 - c2) * theta2 + beta * (1.0 - theta2) * (c2 - x3),
	       Op5 = coef - delta * (x3 - c1) * theta1;

	sol4 = RHS4 / Op4;
	sol5 = RHS5 / Op5;

	double error = max((sol1 - x1).Amax(),max((sol2 - x2).Amax(),max((sol3 - x3).Amax(),max((sol4 - x4).Amax(),(sol5 - x5).Amax()))));

	x1 = sol1; x2 = sol2; x3 = sol3; x4 = sol4; x5 = sol5;

	return error;
}
예제 #3
0
int main()
{
    eoPop<DualVector> pop;

    // fixed test
    DualVector sol1(2,-1);
    DualVector sol2(2,-1);
    DualVector sol3(2,1);
    DualVector sol4(2,1);
    pop.push_back( sol1 );
    pop.push_back( sol2 );
    pop.push_back( sol3 );
    pop.push_back( sol4 );
    // on the sphere function everyone has the same fitness of 1
    if( test(pop, 0) != 0 ) {
        exit(1);
    }

    pop.erase(pop.begin(),pop.end());

    // fixed test
    sol1 = DualVector(2,0);
    sol2 = DualVector(2,0);
    sol3 = DualVector(2,1);
    sol4 = DualVector(2,1);
    pop.push_back( sol1 );
    pop.push_back( sol2 );
    pop.push_back( sol3 );
    pop.push_back( sol4 );
    if( test(pop, 1) != 1 ) {
        exit(1);
    }

    // test on a random normal distribution
    eoNormalGenerator<double> normal(1,rng);
    eoInitFixedLength<DualVector> init_N(2, normal);
    pop = eoPop<DualVector>( 1000000, init_N );
    double iqr = test(pop, 1.09);
    if( iqr < 1.08 || iqr > 1.11 ) {
        exit(1);
    }
}