Adaptive Search



A Library to Solve CSPs
Edition 1.1, for Adaptive Search version 1.0.0





























by Daniel Diaz, Philippe Codognet and Salvador Abreu


 





























Copyright (C) 2002-2010 Daniel Diaz, Philippe Codognet and Salvador Abreu

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.

1  Introduction

The Adaptive Search library provides a set of functions to solve CSPs by a local search method. For more information consult [1] The current release only works for problems that can be stated as permutation problems. More precisely, all n variables have a same domain x1 .. xn and are subject to an implicit all-different constraint. Several problems fall into this category and some examples are provided with the library.

2  Installation

Please refer to the file called INSTALL located in the src subdirectory.

3  The Adaptive Search API

3.1  Overall usage

The typical use of the API is as follows:

To use the API a C file should include the header file ad_solver.h:

#include "ad_solver.h"

Obviously the C compiler must be invoked with the adequate option to ensure the header file can be found by the preprocessor.

At link time, the library called libad_solver.a must be passed. Here also, some options might have to be passed to the C compiler to allow the linker to locate the library.

If both the include file and the library are in the same directory as the user C file (for instance problem.c), then the following Unix command line (using gcc) suffices:

gcc -o problem problem.c libad_solver.a

If the include file is in /usr/adaptive/include and the library in /usr/adaptive/lib, a possible invocation could be:

gcc -I/usr/adaptive/include -L/usr/adaptive/lib -o problem problem.c -lad_solver

A structure (C type AdData) is used to communicate with the solver. Fields in this structure can be decomposed in: input or output data (or input-output). Input parameters are given to the solver and should be initialized before calling the solver. Output parameters are provided by the solver.

Please look at the header file for more information about the fields in the AdData type. We here detail the most important parameters.

3.2  Input parameters

The following input variables control the basic data and have to be initialized before calling the resolution function.

The following input parameters make it possible to tune the solver and should be initialized before calling the resolution function.

3.3  Output parameters

In addition to the array containing the solution, the solver maintains counters that can be consulted by the user to obtain some information about the resolution.

3.4  Miscellaneous parameters

The following variables are not used by the solver. They simply convey values for the user. It is particularly useful for multithreading. It also contains some information related to the default main() function.

3.5  Functions

Here is the set of functions provided by the library:

3.6  User functions

The function Ad_Solve() calls some user functions to guide its resolution. Some functions are MANDATORY while others are OPTIONAL. Here is the set of user functions:

4  Other utility functions

To use this functions the user C code should include the file tools.h.

5  Using the default main() function

The user is obviously free to write his own main() function. In order to have a same command-line options for all bechmarks a default main() is included in the library (it is then used if no user main() is found at link-time). The default function act as follows:

In addition to the variables described above, the following parameters are available when using the default main():

The default default main() function needs an additional function to check the validity of a solution. The user must then provide a function int Check_Solution(AdData *p_ad) which returns 1 if the solution passed in p_ad is valid. A Simple definition for this function could be to simply test if the cost of the solution is 0 (not very precise as verification).

Please look at the examples for more details.

References

[1]
P. Codognet and D. Diaz. Yet Another Local Search Method for Constraint Solving. In Proc. SAGA01, 1st International Symposim on Stochastic Algorithms : Foundations and Applications, LNCS 2246, Springer Verlag 2001

This document was translated from LATEX by HEVEA.