source: releases/1.0.0/makefile

Last change on this file was 7, checked in by cgroer, 11 years ago

cgroer adding releases/1.0.0 and stable/1.0 and copying trunk to these dirs

File size: 6.4 KB
Line 
1# Set compiler and flags
2CC=g++
3CFLAGS= -O3 -Wall
4
5# Set directory for static library and binaries
6# Defaults to ./lib and ./bin
7VRPH_LIB_DIR = ./lib
8VRPH_BIN_DIR = ./bin
9
10# Set names of executables
11RTR_EXE = $(VRPH_BIN_DIR)/vrp_rtr
12EJ_EXE = $(VRPH_BIN_DIR)/vrp_ej
13SP_EXE = $(VRPH_BIN_DIR)/vrp_sp
14SA_EXE = $(VRPH_BIN_DIR)/vrp_sa
15INIT_EXE = $(VRPH_BIN_DIR)/vrp_init
16PLOT_EXE = $(VRPH_BIN_DIR)/vrp_plot
17
18# Set name of libraries needed by applicaitons
19LIBS= -lvrph -lm
20
21# Set to 0 if you don't have/want Doxygen installed for
22# documentation
23HAS_DOXYGEN=1
24ifeq ($(HAS_DOXYGEN),1)
25DOX=doxygen
26DOXYFILE=./Doxyfile
27else
28DOX=
29DOXYFILE=
30endif
31
32# Set to 0 if you don't have PLPLOT, 1 if you do
33# and modify the directories below
34HAS_PLPLOT= 0
35ifeq ($(HAS_PLPLOT),1)
36PLPLOT_INC_DIR= -I$(HOME)/PLPLOT/plplot-5.9.4/x86_64build/include/plplot/
37PLPLOT_LIB_DIR= -L$(HOME)/PLPLOT/plplot-5.9.4/x86_64build/lib/
38PLPLOT_LIB= -lplplotd -lqsastime -lnistcd
39PLDEF=-DHAS_PLPLOT
40else
41PLPLOT_INC_DIR= 
42PLPLOT_LIB_DIR=
43PLPLOT_LIB=
44PLDEF=
45endif
46
47# Set to 0 if you don't have OSI and GLPK, 1 if you do
48# and correct the directories below
49HAS_OSI_GLPK= 0
50ifeq ($(HAS_OSI_GLPK),1)
51GLPK_INC_DIR= -I$(HOME)/GLPK/include
52GLPK_LIB_DIR= -L$(HOME)/GLPK/lib
53GLPK_DEF=-DHAS_GLPK
54OSI_DEF=-DHAS_OSI
55OSI_INC_DIR= -I$(HOME)/OSI/x86_64_build/include/coin
56OSI_LIB_DIR=-L$(HOME)/OSI/x86_64_build/lib
57GLPK_LIBS= -lglpk
58OSI_LIBS= -lOsiGlpk -lOsi -lCoinUtils
59else
60OSI_DEF=
61GLPK_DEF=
62GLPK_INC_DIR=
63OSI_INC_DIR=
64OSI_GLPK_INC_DIR=
65endif
66
67# Various directories needed by the library and applications
68INC_DIR= -I./inc/
69LIB_DIR = -L$(VRPH_LIB_DIR)
70VRPH_LIB = $(VRPH_LIB_DIR)/libvrph.a
71TEST_OUTPUT = ./test_sols.out
72SRCS= ./src/ClarkeWright.cpp ./src/Concatenate.cpp ./src/CrossExchange.cpp ./src/MoveString.cpp \
73./src/OnePointMove.cpp ./src/OrOpt.cpp ./src/Postsert.cpp ./src/Presert.cpp ./src/Flip.cpp \
74./src/RNG.cpp ./src/Swap.cpp ./src/SwapEnds.cpp ./src/Sweep.cpp ./src/ThreeOpt.cpp \
75./src/ThreePointMove.cpp ./src/VRPTSPLib.cpp ./src/TwoOpt.cpp ./src/TwoPointMove.cpp ./src/VRP.cpp \
76./src/VRPIO.cpp ./src/VRPDebug.cpp ./src/VRPMove.cpp  ./src/VRPNode.cpp ./src/VRPRoute.cpp \
77./src/VRPSolution.cpp ./src/VRPSolvers.cpp ./src/VRPTabuList.cpp ./src/VRPUtils.cpp ./src/VRPGraphics.cpp
78
79OBJS=$(SRCS:.cpp=.o)
80
81RTR_SRC= ./src/apps/vrp_rtr.cpp
82SP_SRC= ./src/apps/vrp_glpk_sp.cpp
83SA_SRC= ./src/apps/vrp_sa.cpp
84EJ_SRC= ./src/apps/vrp_ej.cpp
85INIT_SRC= ./src/apps/vrp_initial.cpp
86PLOT_SRC= ./src/apps/vrp_plotter.cpp
87
88all: $(VRPH_LIB) vrp_rtr vrp_sa vrp_init vrp_ej vrp_sp vrp_plot
89
90$(VRPH_LIB): $(OBJS)
91        mkdir -p $(VRPH_LIB_DIR)
92        $(AR) $(ARFLAGS) $@ $(OBJS)
93        ranlib $@
94        rm -rf $(OBJS)
95       
96.cpp.o:
97        $(CC) $(CFLAGS) $(PLDEF) -c $(INC_DIR) $(PLPLOT_INC_DIR) $< -o $@
98
99# An implementation of an RTR-based algorithm for generating solutions
100vrp_rtr: $(OBJS) $(RTR_SRC)
101        mkdir -p $(VRPH_BIN_DIR)
102        $(CC) $(CFLAGS) $(PLDEF) $(PLPLOT_INC_DIR) $(RTR_SRC) $(INC_DIR) $(LIB_DIR) $(PLPLOT_LIB_DIR) $(LIBS) $(PLPLOT_LIB) -o $(RTR_EXE) 
103
104# An implementation of a Simulated Annealing-based algorithm for generating solutions
105vrp_sa: $(OBJS) $(SA_SRC)
106        mkdir -p $(VRPH_BIN_DIR)
107        $(CC) $(CFLAGS) $(PLDEF) $(PLPLOT_INC_DIR) $(SA_SRC) $(INC_DIR) $(LIB_DIR) $(PLPLOT_LIB_DIR) $(LIBS) $(PLPLOT_LIB) -o $(SA_EXE) 
108
109# An implementation of a simple routine that demonstrates the Clarke Wright and Sweep algorithms
110vrp_init: $(OBJS) $(INIT_SRC)
111        mkdir -p $(VRPH_BIN_DIR)
112        $(CC) $(CFLAGS) $(INIT_SRC) $(INC_DIR) $(LIB_DIR) $(LIBS) -o $(INIT_EXE) 
113
114# An implementation of a tool to plot solutions using PLPLOT
115vrp_plot: $(OBJS) $(PLOT_SRC)
116ifeq ($(HAS_PLPLOT),1)
117        mkdir -p $(VRPH_BIN_DIR)
118        $(CC) $(CFLAGS) $(INC_DIR) $(PL_DEF) $(PLPLOT_INC_DIR) $(PLPLOT_LIB_DIR) $(LIB_DIR) $(PLOT_SRC) $(LIBS) $(PLPLOT_LIB) -o $(PLOT_EXE)
119endif
120
121# A utility to improve solutions by ejecting/injecting random neighborhoods
122vrp_ej: $(OBJS) $(EJ_SRC)
123        mkdir -p $(VRPH_BIN_DIR)
124        $(CC) $(CFLAGS) $(INC_DIR) $(EJ_SRC) $(LIB_DIR) $(LIBS) -o $(EJ_EXE)
125
126# An implementation combining RTR with GLPK and OSI
127# Only builds if USE_OSI_GLPK=1 above in this makefile
128vrp_sp: $(OBJS) $(SP_SRC)
129ifeq ($(HAS_OSI_GLPK),1)
130        mkdir -p $(VRPH_BIN_DIR)
131        $(CC) $(CFLAGS) $(INC_DIR) $(OSI_INC_DIR) $(GLPK_INC_DIR) $(OSI_LIB_DIR) $(GLPK_LIB_DIR) $(LIB_DIR) $(SP_SRC) $(LIBS) $(GLPK_LIBS) $(OSI_LIBS) -o $(SP_EXE)
132endif
133
134
135# test - just run the binaries on the test_instance
136# output is sent to $(TEST_OUTPUT) file
137test:
138        -rm -rf $(TEST_OUTPUT).tmp
139        -rm -rf $(TEST_OUTPUT)
140        @echo "*************************************"
141        @echo Testing vrp_rtr on test_instance.vrp
142        ./bin/vrp_rtr -f ./test_instance.vrp -v >> $(TEST_OUTPUT).tmp
143        @echo "*************************************"
144        @echo Testing vrp_sa on test_instance.vrp
145        ./bin/vrp_sa -f ./test_instance.vrp -v >> $(TEST_OUTPUT).tmp
146        @echo "*************************************"
147        @echo Testing vrp_init on test_instance.vrp
148        ./bin/vrp_init -f ./test_instance.vrp -m 0 >> $(TEST_OUTPUT).tmp
149        @echo "*************************************"
150        @echo Testing vrp_ej on test_instance.vrp
151        ./bin/vrp_ej -f ./test_instance.vrp -j 15 -t 500 -m 0 -v >> $(TEST_OUTPUT).tmp
152ifeq ($(HAS_OSI_GLPK),1)
153        @echo "*************************************"
154        @echo Testing vrp_sp on test_instance.vrp
155        ./bin/vrp_sp -f ./test_instance.vrp -n 5 -v >> $(TEST_OUTPUT).tmp
156endif   
157
158ifeq ($(HAS_PLPLOT),1)
159        @echo "*************************************"
160        @echo Testing vrp_plot on test_instance.vrp
161        ./bin/vrp_rtr -f ./test_instance.vrp -out test_instance.sol > /dev/null
162        ./bin/vrp_plot -f ./test_instance.vrp -s test_instance.sol -p test_instance.ps >> $(TEST_OUTPUT).tmp
163        @echo Postscript plot created in test_instance.ps
164        -rm test_instance.sol
165endif   
166        mv $(TEST_OUTPUT).tmp $(TEST_OUTPUT)
167        @echo "*************************************"
168        @echo "*************************************"
169        @echo All tests appeared to pass. File $(TEST_OUTPUT) contains results.
170
171# Doxygen automatic documentation generation
172doc: $(DOXYFILE)
173        @echo Creating Doxygen documentation in ./doc directory
174        mkdir -p ./doc
175        $(DOX) $(DOXYFILE)
176        @echo Run pdflatex or latex on ./doc/latex/refman.tex to create Doxygen manual
177
178clean:
179        -rm -rf $(OBJS)
180        -rm -rf $(VRPH_LIB)
181        -rm -rf $(RTR_EXE)
182        -rm -rf $(EJ_EXE)
183        -rm -rf $(SP_EXE)
184        -rm -rf $(SA_EXE)
185        -rm -rf $(PLOT_EXE)
186        -rm -rf $(INIT_EXE)
187        -rm -rf $(TEST_OUTPUT).tmp
188        -rm -rf $(TEST_OUTPUT)
189        -rm -rf test_instance.sol
190        -rm -rf test_instance.ps
191
Note: See TracBrowser for help on using the repository browser.