Beispiel #1
1
int main(int argc, char **argv){
	PetscErrorCode ierr;
	Vec x,b;
	Mat A;
	KSP ksp;

	ierr=PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
	PetscPrintf(PETSC_COMM_WORLD,"]> Initializing PETSc/SLEPc\n");
	
	/*Load data*/
	ierr=loadInputs(&A,&b,&x);CHKERRQ(ierr);
	PetscPrintf(PETSC_COMM_WORLD,"]> Data loaded\n");

	/*Create the KSP context and setup*/
	ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);	
	ierr = KSPSetType(ksp,KSPFGMRES);CHKERRQ(ierr);	
	ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);	
	ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);	
	ierr = KSPSetUp(ksp);CHKERRQ(ierr);	
	PetscPrintf(PETSC_COMM_WORLD,"]> Krylov Solver settings done\n");

	/*Solve the system*/
	PetscPrintf(PETSC_COMM_WORLD,"]> Krylov Solver Launching solving process\n");
	ierr = KSPSolve(ksp, b, x); CHKERRQ(ierr);
	PetscPrintf(PETSC_COMM_WORLD,"]> Krylov Solver System solved\n");

	/*Clean*/
	ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
	ierr = VecDestroy(&b);CHKERRQ(ierr);
	ierr = VecDestroy(&x);CHKERRQ(ierr);
	ierr = MatDestroy(&A);CHKERRQ(ierr);
	PetscPrintf(PETSC_COMM_WORLD,"]> Cleaned structures, finalizing\n");

	/*Finalize PETSc*/
	PetscFinalize(); 

	return 0;
}
Beispiel #2
0
decision ctrBasic::think()
{
    decision decision;

    loadInputs();

    std::pair<bool, int> best_score=front_score;
    decision.turn_right=0;
    decision.turn_left=0;

    if (right_score<best_score)
    {
        best_score=right_score;
        decision.turn_right=1;
        decision.turn_left=0;
    }
    if (left_score<best_score)
    {
        best_score=left_score;
        decision.turn_right=0;
        decision.turn_left=1;
    }

    decision.boost_speed=0;
    decision.boost_defence=0;

    //cerr<<front_score.second<<" "<<right_score.second<<" "<<left_score.second<<"   "<<decision.turn_right<<" "<<decision.turn_left<<endl;
    //if (front_score.second<0 && right_score.second<0 && left_score.second<0) getch();

    if (body_length>=split_treshhold)
    {
        decision.split=1;
        decision.split_length=ceil(split_part);
    }
    else
    {
        decision.split=0;
    }
    return decision;
}
Beispiel #3
0
 HiEqualization::HiEqualization(QString fromListName) :
     Equalization() {
   loadInputs(fromListName);
 }