Final Assignment, Autumn 2013 [pdf format] |
Make sure you have read the whole document before you start to work.
The aim of the final assignment is to revise and develop further the heuristic algorithms for solving the graph coloring problem that have been the object of the previous assignments. We refer to Assignment 0 for a definition of the problem.
The instances that will be used for the final comparison of results are instances of 4000 vertices and edge density of 0.1; 0.5; 0.9. These instances are huge and a binary format is needed to store them. You will need to update your framework to read this format. Read details on this in the Appendix 4 of this document.
A few test instances are made available here:
The main challenge of this final assignment is the size of the instances. Make sure that a solution is returned in each run before the time limit is reached. The time limit is set to 120 seconds. Your program must be optimized and eventually redesigned to handled these huge instances.
All the following points (that have been already addressed in the previous assignments) must be accomplished to pass the exam:
Instance Construction heuristic Metaheuristic # Colors Seconds # Colors G-4000-0.1–00.col.b G-4000-0.1–01.col.b G-4000-0.5–00.col.b G-4000-0.5–01.col.b G-4000-0.9–00.col.b G-4000-0.9–01.col.b
Differently from the previous assignments, the submission will be graded with the 7-steps scale and external censorship. The evaluation of the project is based on the report and the results that will appear on the web page.
Hence, the submission consists of:
It is expected that the feedback provided in the previous assignment is used in the revision of the work.
In addition to the electronic submission you must deposit two printed copies of your report at the teacher’s mailbox in the secretary office. Remember to collect and keep a receipt of the submission.
Reports and codes handed in after the deadline will generally not be accepted. System failures, illness, etc. will not automatically give extra time.
Appendix 3 is copied from Assignment 0, nothing has changed. The report must be placed in doc/.
Start early to test your submission. You can submit as many times as you wish within the deadline. Every new valid submission overwrites the previous submission.
Your archive must decompress as follows:
gcp
must be
src
and
puts the executables in bin
.
Your program will NOT be recompiled; the executable file gcp
in
bin/
will be used for the tests. Makefile
and src/
are required just for debugging purposes in special cases. Additionally,
you are recommended to have the following content, which will however not
be used.
The programs will run on a machine with ubuntu 12.04, hence you can log
in on any machine of the terminal room, compile your program there, and
make sure that it executes.
If your program is written in C or C++ you should compile with the
-lm
and -static
flags.
If your program is written in Java then your bin directory must contain
a jar file that you compiled on an IMADA machine
and a shell executable file called gcp
containing:
!/bin/bash HERE=`dirname $0` java -jar $HERE/gcp.jar $@ |
See in Sec. 4.2 how this file must be changed.
Python users can do the same but with python commands instead.
The executable must run with the following arguments:
-i filename
the instance file
-c filename
the file with the solution in the format
described below
-s #
a random seed
-t #
an integer indicating the time limit in seconds.
for example:
gcp -i ../data/marco10.col -c marco10.sol -s 10 -t 60
All output must go in the standard output and in the solution file. Do not create other files.
The files containing the solution must be named with the name of the
instance (without .col
extension) and with extension
.sol
. The files must be in ASCII format and consist of a single
column of numbers representing the colors to each vertex. Each number
indicates the color for the vertex corresponding to the line
number. Both colors and vertices start at 1. For example:
$ cat marco10.sol 2 3 4 3 2 2 1 ...
indicates that the vertex 1 receives color 2, vertex 2 receives color 3, etc.
Note that the upload and analysis system is still under test and therefore it may have to be fine tuned, hence be patient and contact the teacher if something is not working as it should.
To read the new instances you need to update the framework made available at Assignment 0.
Follow these steps:
src
with the other sources.
Makefile
, add bin2asc.o
among the object files Problem.h
, include bin2asc.h
.Problem.cpp
, change the code that handles the case
BIN_FORMAT
. Precisely, you need to substitute this piece of
code:cout << "...read input in GZIP format..." << endl; exit(1); break; |
with this:
cout << "...read input in BIN format..." << endl; DIMACS_bin_format in(id); num_of_vertices = in.Nr_vert; adjacency_matrix = new unsigned char *[num_of_vertices]; Vertex v, w; for (v = 0; v < num_of_vertices; v++) { adjacency_matrix[v] = new unsigned char[num_of_vertices]; for (w = 0; w < num_of_vertices; w++) adjacency_matrix[v][w] = 0; } for (w = 0; w < in.Nr_vert; w++) { for (v = 0; v <= w; v++) { if (in.get_edge(w, v)) { //printf("e %d %d\n",w+1,v+1 ); if (adjacency_matrix[v][w] == 0) { num_of_edges++; } adjacency_matrix[v][w] = adjacency_matrix[w][v] = 1; } } } assert(num_of_edges == in.Nr_edges); break; |
In case, you can also downloaded the updated framework: FrameworkC++.tgz.
A possibility is to translate the C++ files in Java. Alternatively you can use them as library via SWIG. This has already been prepared for you. You need to follow these steps:
swig
in the root of the
FrameworkJava that was distributed with Assignment 0. Enter in the
swig
directory and compile the library via make
. You
need to compile the package on one of the IMADA machines. It has been
tested on Linux and MacOS.If something goes wrong you can try to download the precompiled package for different architectures:
You will need to include and link the first in the list for the execution on the dedicated machine. If you compile the library on a 32-bit Ubuntu Linux machine, the library will not work on a 64-bit architecture.
Makefile
inside src
, add
../swig/bin2asc.jar
to the class path
manifest
inside meta/
add
../swig/bin2asc.jar
to Class-Path
, thus the content of
the file becomes:
Main-Class: GCP Class-Path: . ../lib/commons-cli-1.2.jar ../swig/bin2asc.jar |
bin/gcp
add
-Djava.library.path="${HERE}/../swig"
, thus its content
becomes:
!/bin/bash HERE=`dirname $0` java -Djava.library.path="${HERE}/../swig" -jar $HERE/gcp.jar $@ |
Problem.java
. To do this you must add inside the class Problem
: static { try { System.loadLibrary("bin2asc"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); System.exit(1); } } |
and then use the library in the constructor of the class Problem
for example as shown here:
int format = 0; int BIN_FORMAT=1; int ASCII_FORMAT=2; if (filename.contains(".b")) format = BIN_FORMAT; else format = ASCII_FORMAT; if (format == BIN_FORMAT) { System.out.println("Reading in bin format"); DIMACS_bin_format in = new DIMACS_bin_format(filename); //in.write_graph_DIMACS_ascii("tmp.col"); numVertices = in.getNr_vert(); numEdges = in.getNr_edges(); colors = new int[numVertices]; adjacency_list = (List<Integer>[])new List[numVertices]; adj_matrix = new boolean[numVertices][numVertices]; for(int i=0; i < numVertices; i++){ adjacency_list[i] = new ArrayList<Integer>(); for(int j=i; j < numVertices; j++){ adj_matrix[i][j]=false; adj_matrix[j][i]=false; } } for (int u = 0; u < in.getNr_vert(); u++) { for (int v = 0; v < u; v++) { //System.out.println(u+" "+v+"-"+(int) in.get_edge(u, v)+"-"); if (((int) in.get_edge(u, v)==1)) { //printf("e %d %d\n",w+1,v+1 ); adjacency_list[u].add(v); adjacency_list[v].add(u); adj_matrix[u][v]=true; adj_matrix[v][u]=true; } } } } else if (format==ASCII_FORMAT) { System.out.println("Reading in ASCII format"); // The old source code of the constructor } |
In case, you can also downloaded the updated framework: FrameworkJava.tgz.