Fri Mar 25 14:49:22 CET 2005

First module ported to the new kernel

I'm pleased to announce that the first of the 26 modules included in the 0.1.1 release was successfully ported to the new 0.2.0 kernel API. The new kernel still runs only in debug mode without PVM support, but I hope I will be able to fix that soon.

The new code for timeplace.so module is included bellow, to give a demonstration how the new API will look like. You can expect full 0.2.0 API reference to be available on this page soon.

int module_grade(chromo **c, ext **e, slist **s)
{
        int a,b,m;
        int n;
        int sum;
        slist *list;
        chromo *time, *room;

        list=s[0];
        room=c[0];
        time=c[1];

        sum=0;
        for(m=0;m<time->gennum;m++) {
                a=time->gen[m];

                for(n=0;n<list->tuplenum[a];n++)
		if(list->tupleid[a][n]<m) {
                        b=list->tupleid[a][n];
                        if (room->gen[m]==room->gen[b]) {
                                sum++;
                        }
                }
        }

        return(sum);
}

int module_init(moduleoption *opt) 
{
        gradefunc *grade;

        grade=grade_new("time-place", 
                        option_int(opt, "weight"), 
                        option_int(opt, "mandatory"), 
                        module_grade);
        if(grade==NULL) return -1;

        grade_request_chromo(grade, "room");
        grade_request_chromo(grade, "time");

        grade_request_slist(grade, "time");

        return(0);
}

Posted by Tomaz | Categories: Development