示例#1
0
bool TestExtMisc::test_eval() {
  try {
    f_eval("sleep(5);");
  } catch (const NotSupportedException& e) {
    return Count(false);
  }
  return Count(true);
}
示例#2
0
void PluginFit::calculateFitCurveData(double *X, double *Y)
{
	if (d_gen_function) {
		double X0 = d_x[0];
		double step = (d_x[d_n-1]-X0)/(d_points-1);
		for (int i=0; i<d_points; i++){
		    double x = X0+i*step;
			X[i] = x;
			Y[i]= f_eval(x, d_results);
		}
	} else {
		for (int i=0; i<d_points; i++) {
		    double x = d_x[i];
			X[i] = x;
			Y[i]= f_eval(x, d_results);
		}
	}
}
示例#3
0
//Fonction max trouve le maximum des noeuds fils
int f_max(Pion *etat, int profondeur, int joueur, int *la, int *ca, int *lb, int *cb)
{
	int maximumVal = -INFINI;
	if (profondeur == 0 || f_gagnant() != 0)
	{
		if (f_test_mouvement(etat, *la, *ca, *lb, *cb, joueur) == 0)
		{
			return f_eval(etat, joueur);
		}
		else
		{
			return -maximumVal;
		}
	}

	for (int i = 0; i < NB_LIGNES; i++){
		for (int j = 0; j < NB_COLONNES; j++){
			for (int a = -1; a <= 1; a++){
				for (int b = -1; b <= 1; b++){
					Pion *nouveauJeu = f_raz_plateau();
					f_copie_plateau(etat, nouveauJeu);
					if (f_test_mouvement(nouveauJeu, i, j, i + a, j + b, joueur) == 0)
					{
						f_bouge_piece(nouveauJeu, i, j, i + a, j + b, joueur);
						int min = f_min(nouveauJeu, profondeur - 1, joueur, la, ca, lb, cb);
						if (min > maximumVal){
							maximumVal = min;

							*la = i;
							*ca = j;
							*lb = i + a;
							*cb = j + b;
						}
					}
					free(nouveauJeu);
				}
			}
		}
	}
	return maximumVal;

}
示例#4
0
	void Tresidual<T>::jacobian( Tmatrix<T>& J, const Tvector<T>& x_k ) const
	{
		Tvector<T> new_state( ORDER, 0.0 );			// New state vector 
		Tvector<T> f_eval( ORDER, 0.0 );			// Function evaluation
		Tvector<T> f_at_new_state( ORDER, 0.0); 	// Function evaluation at the new state
		for ( std::size_t alpha = 0; alpha < ORDER; ++alpha )	// Row index
		{				
			for ( std::size_t beta = 0; beta < ORDER; ++beta )	// Column index
			{
				Tvector<T> delta(ORDER,0.0); 					// Perturbation vector
				delta[ beta ] += DELTA;
				new_state = x_k + delta;						// Perturb the known value
				
				// Perurbed function evaluation 
				residual_function( f_at_new_state, new_state );
				residual_function( f_eval, x_k );

				// Approximate the entry in the Jacobian
				J(alpha,beta) = ( f_at_new_state[ alpha ] - f_eval[ alpha ] ) / DELTA;
			}
		}
	}