The following article will detail how to compile c++ code to use concert to call CPLEX. The problem was provided by the distribution of cplex. The original makefile etc can be found in the install folder: /opt/ilog/cplex/examples
The modified example files referenced in this article can be found on wren in:
Description taken from Cplex manual*:
"This example illustrates using the Cplex Class API to model and solve a facility location problem.
The problem solved in this is example is a simple version of a facility location problem. A company is considering opening as many as four warehouses in order to serve nine different regions. The goal is to minimize the sum of fixed costs associated with opening warehouses as well as the various transportation costs incurred to ship goods from the warehouses to the regions. Whether or not to open a warehouse is represented by binary variable. Whether or not to ship goods from warehouse i to region j is represented by binary variable. Each region needs a specified amount of goods, and each warehouse can store only a limited quantity of goods. In addition, each region must be served by exactly one warehouse. Constraints also state that warehouse i must be open in order for goods to be shipped from warehouse i to any region."
The data file facility.cpp pulls in to complete the problem
What is a makefile**:
"In software development, Make is a utility that automatically builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program. Though integrated development environments and language-specific compiler features can also be used to manage a build process, Make remains widely used, especially in Unix."
Below is a cookie cutter make file provided mostly by CPLEX. Review and make sure you have a decent understanding on what its doing. The lines in the grey box should be fit to cut/paste into your make file.
Details of the Makefile
`SYSTEM = x86-64_linux` `LIBFORMAT = static_pic` `CPLEXDIR = /opt/ilog/cplex` `CONCERTDIR = /opt/ilog/concert` `CC = g++ -O0` `CCOPT = -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD` `CPLEXBINDIR = $(CPLEXDIR)/bin/$(BINDIST)` `CPLEXLIBDIR = $(CPLEXDIR)/lib/$(SYSTEM)/$(LIBFORMAT)` `CONCERTLIBDIR = $(CONCERTDIR)/lib/$(SYSTEM)/$(LIBFORMAT)` `CCLNDIRS = -L$(CPLEXLIBDIR) -L$(CONCERTLIBDIR)` `CLNDIRS = -L$(CPLEXLIBDIR)` `CCLNFLAGS = -lconcert -lilocplex -lcplex -lm -lpthread` `all: facility` `CONCERTINCDIR = $(CONCERTDIR)/include` `CPLEXINCDIR = $(CPLEXDIR)/include` `CCFLAGS = $(CCOPT) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR)` `clean :` `/bin/rm -rf *.o *~ *.class facility` `/bin/rm -rf *.mps *.ord *.sos *.lp *.sav *.net *.msg *.log *.clp` `facility: facility.o` `$(CC) $(CCFLAGS) $(CCLNDIRS) -o facility facility.o $(CCLNFLAGS)` `facility.o: facility.cpp` `$(CC) -c $(CCFLAGS) facility.cpp -o facility.o`
To compile just run:
To clean or remove the final compiled code (to recompile):
Review the 'clean' lines in the makefile. Make sure its removing all those files produced by the compile but not necessary to recompile if you need to.