-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started
- git
- CPLEX
- Eclipse
See this website for operating system specific installation instructions:
From the terminal, go to the directory where you want store your code, e.g.
ross@rosslaptop:~$ mkdir ~/git
ross@rosslaptop:~$ cd ~/git
Now your terminal should look like this:
ross@rosslaptop:~/git$
You can store the code where ever you want. Run the command
ross@rosslaptop:~/git$ git clone [email protected]:rma350/kidneyExchange.git
This should create a new directory kidneyExchange
inside git
and everything will be inside.
Open eclipse in whatever workspace you want. I like to use one workspace per project, e.g. ~/workspaces/kidneyWorkspace/
Select File -> Import -> General -> Existing Projects into Workspace
then hit Next
.
Under Select root directory
, browse to the the folder kidneyMatching
inside the git repo. For example, in my setup, the full path would be
~/git/kidneyExchange/kidneyMatching
Back in the eclipse import window, under Projects
, you should see that it found one project kidneyMatching
, and that it is checked. Now click Finish
.
If all goes well, you should see the project in the Package Explorer, but under Problems, you will see an error because lib/lib64/cplex125.jar
is missing.
Add the subdirectory lib64
to lib
, and then take the file cplex.jar
from your CPLEX installation, rename it to cplex125.jar
, and put it in the lib64
directory. If you are on linux and installed CPLEX in default location, you can find the jar here:
/opt/ibm/ILOG/CPLEX_Studio125/cplex/lib/cplex.jar
After you add the jar, the build errors should go away.
To make sure you have configured
In the package explorer, find the folder kidneyMatching -> test
and right click on test
. Select Run as -> JUnit Test
. Some tests will pass, and but those depending on CPLEX will fail. CPLEX is a c program, and our cplex125.jar
is just a Java wrapper around the actual program. We need to tell Java where to find the CPLEX c library. To do this, right click on test
, then select Run as -> Run Configurations...
. A new window will pop up. The selected configuraiton should be a JUnit test that runs all tests in the directory test
. Click on the Arguments
tab. Under VM arguments, direct Java to the location of libcplex.so
(linux) from your CPLEX installation, by pasting the following into the VM arguments text area:
-Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio125/cplex/bin/x86-64_sles10_4.1
Here, /opt/ibm/ILOG/CPLEX_Studio125/cplex/bin/x86-64_sles10_4.1
the directory containing the file libcplex.so
. Adjust this path appropriately for your installation.
Now run your test again (either by hitting the run button in the run configurations menu, or by closing the run configuration menu and repeating the previous procedure for running tests). They should all pass (except the dynamic programming test, which at the moment is not yet implemented).
Under the folder kidneyMatching
, create a subdirectory output
where we can store the result of running the program. The .gitignore will prevent the contents of this directory from being added to version control.
While the program is not distributed with any real data, you can run it on a small example. In the package explorer, navigate to src/main/CommandLineInterface.java
, and right click on the file. Select Run As -> Run Configurations...
Go to the arguments tab again. In the VM arguments box, paste the same location for libcplex.so
as when we were running tests (you can navigate to our test configuration on the left of the Run Configurations window to copy it).
In program arguments, paste:
-mode deterministicMode -kepIn kepLibInstances/examples/kepLibExample.csv -optPackingOut output/exampleOutputPacking.csv
Now run the program (by clicking run). In the console, you should see some text printed to standard out and standard error by the program and CPLEX. The results should be in the newly created output folder (you may have to right click on the folder and hit refresh to view it from eclipse).
The program contains several other entry points with different functionality. All of the main methods are under the directory src/main
.
If you want to run your code outside of eclipse, which may be useful if you need to distribute an executable version of the program, you can make a JAR. Select File -> Export
, then Java -> Runnable JAR file
, and hit Next
. Under Launch configuration, select CommandLineInterface - kidneyMatching
. Under export destination, set the file name of the jar you want to generate with its location, e.g.
kidneyMatching/kidneyMatching125.jar
You can check the Save as ANT script box if you want to make this procedure repeatable. You may want to save the file at
kidneyMatching/buildKidneyMatching125.xml
Click Finish
. You will get a warning about software licences. Click OK. Now you should see kidneyMatching125.jar
.
You can run your jar from the command line with the command
ross@rosslaptop:~/git/kidneyExchange/kidneyMatching/$ java -jar -Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio125/cplex/bin/x86-64_sles10_4.1 -mode deterministicMode -kepIn kepLibInstances/examples/kepLibExample.txt -optPackingOut output/exampleOutputPacking.csv