                             COPYRIGHT NOTICE

This software is copyright by Zbigniew Michalewicz. Permission is
granted to copy and use the software for scientific, noncommercial 
purposes only. The software is provided "as is", i.e., without any
warranties.

                              GENERAL REMARKS
The genetic2n aims at solving the nonlinear transportation problem
(minimization of the transportation cost). 
The system was described in an article "A Non-Standard Genetic 
Algorithm for the Nonlinear Transportation Problem", 
ORSA Journal on Computing, Vol.3, No.4, 1991, pp.307--316.
It is also described in my new book "Genetic Algorithms + Data Structures = 
Evolution Programs" (Springer Verlag, August 1992).

The system was build over 3 years ago. It is the first and last
version (I do not plan to work on the system in the future).
It is quite primitive with almost all variables global. However, the
ease of use is its main advantage. It is quite interesting to
compare the results of this system with some commercial packages
for several transportation problems with difficult transportation
cost functions.

The current version of genetic2n should run without changes on any BSD-UN*X
system (preferably on a Sun SPARC machine). Note, however, that the 
system was NOT designed with portability in mind, i.e., the partability 
was not the main factor in the design process. 

                        HOW TO RUN THE GENETIC2N SYSTEM

To run the genetic2 system, there are four simple steps to follow:

(1) prepare input file, say, "your_input",
(2) provide your transportation cost functions in the file "eval.c",
(3) type "make"
(4) type "genetic2n < your_input > your_output" ("your_output" is the name 
    of the output file provided by you).

A simple example follows. The input file of this example is the
transferred file "input" you have now in your directory, the typical 
output is present in the file "output". 

INPUT FILE  (and the explanations, line by line. Note that the
             explanations are NOT present in the real input file):

____________________________________________________

# Problem #12                 /* comment line   */
nsource   5                   /* number of sources  */
ndest	  5                   /* number of destinations */
sources
8.0 7.0 9.0 3.0 5.0           /* all source values */
dests
6.0 8.0 10.0 4.0 4.0          /* all destinations values */
costs
73.0 40.0  9.0 79.0 20.0      /* the cost matrix, which might be
62.0 93.0 96.0  8.0 13.0         helpful in defining nonlinear
96.0 65.0 80.0 50.0 65.0         transportation cost function */
57.0 58.0 29.0 12.0 87.0
56.0 23.0 87.0 18.0 12.0
optimum   0.0                    /* if optimum is known, you can place
                                    its value here */
pop	 50                      /* population size */
cross	  6                      /* number of crossovers per generation */
inver     0                      /* inversion is NOT implemented; keep it
                                    zero all the time */
mutat     10                     /* number of mutations per generation */
cross_1   0.2                    /* a coeficient for arithmetical crossover */
cross_2   0.8                    /* a coeficient for arithmetical crossover */
                                 /* note that cross_1 + cross_2 MUST equal to 1 */
sprob	  0.9                    /* a coefficient for probability distribution */
it          500                  /* number of generations */
fixed     0.0                    /* a parameter useful for defining the
                                    transportation costs */
run 200                          /* run id */
seed	  1                      /* seed */

run 201                          /* for additional runs with different seeds */
seed      1313

run 203
seed      3337

end

___________________________________________________

The output is given in the "output" file; it is self-explanatory.

IMPORTANT REMARKS:
(1) the maximum sizes of the number of sorces, destinations, and the
population size are given in the genet.h file. If you run larger
example, change these maximum values first.
(2) keep the total of crossovers and mutations (cross + mutat) at
approx. 25% of the population size for the best results.
(3) there is a parameter "licz" in the genet.h file; 
licz = 2147483647.0. This represents the largest integer number 
(converted into float) which can be generated by the standard function
rand(). You may have to change this constant in your system.
(4) the values for sources, destinations, cost matrix, and the variable
fixed are float numbers.

Now you have to provide the transportation costs by editing the file eval.c.

TRANSPORTATION COSTS:
The example transportation costs are given in the following part of the
eval.c file:

______________________________________________

for (p=0;p<pop;++p){
   sum=0.0;
   for (i=0; i<k; ++i)
       for (j=0;j<n;++j){
           if ((pp[p]->sol[i][j]) > epsilon)
           {sum = sum + fixed + cost[i][j]*sqrt(pp[p]->sol[i][j]);}}
                            
   pp[p]->eval = sum;}
}
___________________________________________________________

In the above example, pp[p]->sol[i][j] represents the i-th source value,
and the j-th destination value (i.e., x[i][j] element of the
transportation plan) of the p-th element of the population.
In buiding a total transportation cost, you can use a constant
fixed charge "fixed" and the coefficient matrix cost[i][j] which
was read from the input file. 
So you have to replace two lines:
           if ((pp[p]->sol[i][j]) > epsilon)
           {sum = sum + fixed + cost[i][j]*sqrt(pp[p]->sol[i][j]);}}
by your own routine.


Now, everything is ready. Just type:

% make
and
% genetic2n < your_input > your_ouput

and (hopefully) you'll get your result.


I hope this information would be sufficient to run the system.


Zbigniew Michalewicz

******************************************************************************
* Mail: Department of Computer Science      E-mail: zbyszek@mosaic.uncc.edu  *
*       University of North Carolina        Phone:  (704) 547-4873           *
*       Charlotte, NC 28223                 Fax:    (704) 547-2352           *
******************************************************************************






