Beispiel #1
0
int main()
{
	init_random(); // set the random generator seed
	init_ga(); // initialise and evaluate population
	display(); // display initial state

	// evolve population
	while(evals < MAX_EVALS) {
		SF child = create_child();
		eval(&child);
		add_offspring(&child);
		// display output when necessary
		if(evals % DISP_EVALS == 0)
			display();
	}

	// print best shape found
	SF best = pop[fittest_individual()];
	print_sf(&best);

	// write best to stl
//	_Bool grid[GRID_SIZE][GRID_SIZE][GRID_SIZE];
//	draw_super_formula( best.genome, grid );
//	write_stl( grid, "best.stl" );

	return EXIT_SUCCESS;
}
Beispiel #2
0
bool update_forcefield(FILE *fplog,
                       int nfile,t_filenm fnm[],t_forcerec *fr,
                       int natoms,rvec x[],matrix box)
{
    static int ntry,ntried;
    int    i,j;
    bool   bDone;

    /* First time around we have to read the parameters */
    if (nparm == 0) {
        range = read_range(ftp2fn(efDAT,nfile,fnm),&nparm);
        if (nparm == 0)
            gmx_fatal(FARGS,"No correct parameter info in %s",ftp2fn(efDAT,nfile,fnm));
        snew(param_val,nparm);

        if (opt2bSet("-ga",nfile,fnm)) {
            /* Genetic algorithm time */
            ga = init_ga(fplog,opt2fn("-ga",nfile,fnm),nparm,range);
        }
        else {
            /* Determine the grid size */
            ntry = 1;
            for(i=0; (i<nparm); i++)
                ntry *= range[i].np;
            ntried = 0;

            fprintf(fplog,"Going to try %d different combinations of %d parameters\n",
                    ntry,nparm);
        }
    }
    if (ga) {
        update_ga(fplog,range,ga);
    }
    else {
        /* Increment the counter
         * Non-trivial, since this is nparm nested loops in principle
         */
        for(i=0; (i<nparm); i++) {
            if (param_val[i] < (range[i].np-1)) {
                param_val[i]++;
                for(j=0; (j<i); j++)
                    param_val[j] = 0;
                ntried++;
                break;
            }
        }
        if (i == nparm) {
            fprintf(fplog,"Finished with %d out of %d iterations\n",ntried+1,ntry);
            return TRUE;
        }
    }

    /* Now do the real updating */
    update_ff(fr,nparm,range,param_val);

    /* Update box and coordinates if necessary */
    scale_box(natoms,x,box);

    return FALSE;
}
Beispiel #3
0
void main_do_aln(Parameter *PARAM)
    {
    Chromosome *R;
    Chromosome *C;
    char fname[200];
    
    
    if ( (PARAM->BGA)->EVALUATE_ONLY==1)
    	{
    	C=declare_chromosome (PARAM);
    	code_chromosome ((PARAM->BGA)->REFERENCE, C, PARAM);
    	save_individual ( C,NULL, 0, PARAM);
    	}
    else
    	{	 			
    	init_ga ( PARAM);
   	}
    }