#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include "main.h"
#include "data.h"
#include "modsup.h"
#include "error.h"
#include "gettext.h"
#include "assert.h"
Functions | |
domain * | domain_new (resourcetype *restype) |
Creates a new full domain. (domain with all possible values for a specified resource type). | |
int | domain_addtuple (domain *dom, tupleinfo *tuple) |
Adds a tuple to a domain. | |
void | domain_and (domain *dom, int *val, int valnum) |
Removes some values from a domain. | |
void | domain_free (domain *dom) |
Free a domain structure. | |
void | domain_freeall () |
Free all domains. | |
int | domain_compare (domain *d1, domain *d2) |
Compare if two domains contain same values. | |
int | compact_domains () |
Finds and merges duplicate domains. | |
int | domain_rand (domain *dom) |
Returns a random value from a domain. | |
int | domain_check (domain *dom, int val) |
Checks if a value is present in a domain. | |
resourcetype * | restype_new (int var, char *type) |
Define a new resource type. | |
int | restype_findid (char *type) |
Find a resource type (either variable or constant) by name and return a resource type ID. | |
resourcetype * | restype_find (char *type) |
Find a resource type by name. | |
void | res_set_conflict (resource *res1, resource *res2) |
Set conflict between resource res1 and resource res2. | |
int | compact_conflicts () |
Generates conflict lookup tables for all defined resource types. | |
resource * | res_new (resourcetype *restype, char *name) |
Add a new resource to a resource type. | |
resource * | res_new_matrix (resourcetype *restype, int width, int height) |
Adds a matrix of resources to a resource type. | |
int | res_get_matrix (resourcetype *restype, int *width, int *height) |
Finds the dimensions of a matrix of resources. | |
int | res_findid (resourcetype *restype, char *name) |
Find a resource by name and return its resource ID. | |
resource * | res_find (resourcetype *restype, char *name) |
Find a resource by name. | |
void | restype_freeall () |
Free all resource types and all resources. | |
void | tuple_set (tupleinfo *tuple, resource *res) |
Set a resource in a tuple. | |
int | tuple_compare (int tupleid1, int tupleid2) |
Compare two events. | |
tupleinfo * | tuple_new (char *name) |
Add a new tuple. | |
void | tuple_freeall () |
Free all tuples. | |
tuplelist * | tuplelist_new () |
Allocate a new empty tuplelist structure. | |
int | tuplelist_add (tuplelist *dest, int tupleid) |
Add a new tupleid to the tuplelist structure. | |
void | tuplelist_free (tuplelist *dest) |
Frees a tuplelist structure. | |
outputext * | outputext_new (char *contype, char *vartype) |
Allocate a new output extension struct. | |
int | outputext_update (outputext *ex, table *tab) |
Update output extension with new data from a timetable. | |
void | outputext_free (outputext *dest) |
Free an output extension struct. | |
ext * | ext_new (ext **ex, int contype, int vartype) |
Allocate a new extension struct in a linked list. | |
void | ext_update (ext *ex, table *tab) |
Update extension with new data from a timetable. | |
slist * | slist_new (slist **list, int vartype) |
Allocate a new slist struct in a linked list. | |
void | slist_update (slist *list, table *tab) |
Update slist with new data from a timetable. | |
int | data_init () |
Prepare data structures for use. | |
void | data_exit () |
Free all memory allocated by restype_new(), res_new(), domain_new() and tuple_new(). | |
static int | table_init (table *tab, int new) |
Helper function for population_init(). | |
population * | population_init (population *pop, int size) |
Initializes population structure. | |
void | population_rand (population *pop) |
Randomize the entire population. | |
void | table_hint (table *tab, int typeid) |
void | population_hint (population *pop, int hintpart) |
Hint a part of the population. | |
Variables | |
miscinfo | dat_info = { title: NULL, address: NULL, author: NULL } |
Miscellaneous information about the timetable. | |
int | dat_typenum = 0 |
Number of all defined resource types. | |
resourcetype * | dat_restype = NULL |
Array of dat_typenum resource types. | |
int | dat_tuplenum = 0 |
Number of all defined tuples (events). | |
tupleinfo * | dat_tuplemap = NULL |
Array of dat_tuplenum tuples. | |
domain * | dat_domains = NULL |
Linked list of defined domains. |
|
Generates conflict lookup tables for all defined resource types.
|
|
Finds and merges duplicate domains. This function must be called after all tuples were added.
|
|
Prepare data structures for use.
|
|
Adds a tuple to a domain.
|
|
Removes some values from a domain. This function removes all values from dom domain that are not in the val list.
|
|
Checks if a value is present in a domain.
|
|
Compare if two domains contain same values.
|
|
Free a domain structure.
|
|
Creates a new full domain. (domain with all possible values for a specified resource type). The allocated domain contains no tuples.
|
|
Returns a random value from a domain.
|
|
Allocate a new extension struct in a linked list. Linked list is first searched for an identical extension struct. If such a structure is found, only a pointer to it is returned and the linked is is not changed. If no such structure exists, a new structure is allocated and inserted at the beginning of the linked list.
|
|
Update extension with new data from a timetable.
|
|
Free an output extension struct.
|
|
Allocate a new output extension struct.
|
|
Update output extension with new data from a timetable.
|
|
Hint a part of the population. If dat_tuplemap contains information that can be used to initialize variable chromosomes in the population (i.e. the user has loaded an XML file that already contains a partial or a full solution), then this function initializes some variable chromosomes. If dat_tuplemap doesn't contain this information this function does nothing. If the information in dat_tuplemap conflicts with a domain of a tuple then the dat_tuplemap information is ignored for that tuple and an error is reported.
|
|
Initializes population structure. All resources, resource types and tuples (events) must be defined before calling this function. If pop is NULL, a new structure with population size size is allocated using the number of tuples and resource types. If pop is not NULL then only proper links to resources, etc. are made. Checks are also performed to see if population pop is compatible with the number of defined resource types, etc. size parameter is not used in this case.
|
|
Randomize the entire population. All variable chromosomes in the population are filled with random values (domains of individual tuples, as specified in dat_tuplemap are respected)
|
|
Find a resource by name.
|
|
Find a resource by name and return its resource ID.
|
|
Finds the dimensions of a matrix of resources. This function finds the width and height of a matrix of resources that was defined by the res_new_matrix() function. There must be no other resources defined in the specified resource type.
|
|
Add a new resource to a resource type. After the first resource was added, any calls to restype_new() have unspecified effects.
|
|
Adds a matrix of resources to a resource type. This function adds width * height new resources to the specified resource type. New resources have names "x y", where x goes from 0 to width -1 and y goes from 0 to height -1. Resources are ordered first by y and then by x. For example:
x=resid/height; y=resid%height; If there were no resources added to the resource type before the res_new_matrix() function was called, x now holds the x coordinate and y the y coordinate of the resource with resid resource ID in the matrix.
|
|
Set conflict between resource res1 and resource res2. Resources must be of the same type. In most cases you must call this function twice:
res_set_conflict(res1, res2); res_set_conflict(res2, res1);
|
|
Find a resource type by name.
|
|
Find a resource type (either variable or constant) by name and return a resource type ID.
|
|
Define a new resource type.
|
|
Allocate a new slist struct in a linked list. Linked list is first searched for an identical slist struct. If such a structure is found, only a pointer to it is returned and the linked is is not changed. If no such structure exists, a new structure is allocated and inserted at the beginning of the linked list.
|
|
Update slist with new data from a timetable.
|
|
Compare two events. Two events are considered equal (for example, they were defined as repeats of a single <event> tag), if their names are equal and if they have the same constant resources.
|
|
Add a new tuple. After the first tuple was added, any calls to restype_new() and res_new() have unspecified effects. Tuples are independent by default.
|
|
Set a resource in a tuple. Note that only one resource of each type can be used in a tuple.
|
|
Add a new tupleid to the tuplelist structure.
|
|
Frees a tuplelist structure.
|
|
Allocate a new empty tuplelist structure.
|