Logo Search packages:      
Sourcecode: tablix version File versions  Download package

teacher_first_last.c

/* TABLIX, PGA highschool timetable generator                              */
/* Copyright (C) 2002-2005 Tomaz Solc                                      */

/* This program is free software; you can redistribute it and/or modify    */
/* it under the terms of the GNU General Public License as published by    */
/* the Free Software Foundation; either version 2 of the License, or       */
/* (at your option) any later version.                                     */

/* This program is distributed in the hope that it will be useful,         */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of          */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           */
/* GNU General Public License for more details.                            */

/* You should have received a copy of the GNU General Public License       */
/* along with this program; if not, write to the Free Software             */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

/* $Id: teacher_first_last.c,v 1.2 2005/06/04 16:34:47 avian Exp $ */

/* 
 * AUTHOR:
 *
 *  Antonio Duran Terres <antonio.duran.terres@gmail.com>
 *
 * DESCRIPTION:
 *
 *  Adds a weight whenever a teacher has lessons in the last period of a
 *  day and in the first period of the next.
 *
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "modsup.h"
#include "data.h"
#include "gettext.h"

int init_mod()
{
      return 0;
}

int grade_function(chromo *t, int *cpnt, int *tpnt, int **start, int **lead)
{
      int *pnt;
        int day,tid;
        int sum;

        sum=0;
      pnt=tpnt;
        for(tid=0;tid<tmapnum;tid++) {
                        for(day=0;day<DAYS - 1;day++) { // Dont check last day
                        pnt += (PERIODS - 1);   // Go to the last period of the day
                        if(*pnt!=-1) {          // If lesson scheduled
                              pnt++;            // Go to the first period of the next day
                              if (*pnt != -1)
                              {
                                    sum++; // Has lesson scheduled
                              }
                        }
                        else pnt++;
                        }
                  pnt+=PERIODS;     // Go to the first period of the first day of the next teacher
        }

      return(sum);
}

Generated by  Doxygen 1.6.0   Back to index