forked from dennisegen/MOST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSOURCES
204 lines (122 loc) · 5.47 KB
/
SOURCES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
The GNU Linear Programming Kit (GLPK) package supplies a solver for large scale linear programming (LP) and mixed integer programming (MIP). The GLPK project is hosted at http://www.gnu.org/software/glpk.
It has two mailing lists:
To subscribe to one of these lists, please, send an empty mail with a Subject: header line of just "subscribe" to the list.
GLPK provides a library written in C and a standalone solver.
The source code provided at ftp://gnu.ftp.org/gnu/glpk/ contains the documentation of the library in file doc/glpk.pdf.
The Java platform provides the Java Native Interface (JNI) to integrate non-Java language libraries into Java applications.
Project GLPK for Java delivers a Java Binding for GLPK. It is hosted at http://glpk-java.sourceforge.net/.
To report problems and suggestions concerning GLPK for Java, please, send an email to the author at [email protected].
====================================
installing GLPK and GLPK for Java
====================================
========Windows========
The following description assumes:
You are using a 64-bit version of Windows. Replace folder name w64 by w32 if you are using a 32-bit version.
The current version of GLPK is 4.54. Please adjust pathes if necessary.
Your path for program files is "C:\Program Files". Please adjust pathes if necessary.
The GLPK library (glpk_4_54.dll) is in the search path for binaries specified by the environment variable PATH.
Download the current version of GLPK for Windows from https://sourceforge.net/projects/winglpk/.
The filename for version 4.54 is winglpk-4.54.zip. Unzip the file. Copy folder glpk-4.54 to "C:\Program Files\GLPK\".
To check the installation run the following command:
"C:\Program Files\GLPK\w64\glpsol.exe" --version
To use GLPK for Java you need a Java development kit to be installed. The Oracle JDK can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/index.html.
To check the installation run the following commands:
"%JAVA_HOME%\bin\javac" -version
java -version
========Linux and Mac OS X========
For Debian and Ubuntu an installation package for GLPK for Java exists. It can be installed by the following commands:
sudo apt-get install libglpk-java
The installation path will be /usr in Linux and in /usr/local in Mac as assumed in the examples below.
Installation from source
Prerequisites
To build glpk-java you will need the following
gcc
libtool
SWIG
GLPK
Java JDK
For Debian and Ubuntu the following packages should be installed
build-essential
glpk
openjdk-7-jdk or openjdk-6-jdk
libtool
swig
The installation command is:
sudo apt-get install build-essential glpk openjdk-7-jdk libtool swig
For Fedora the following packages should be installed
gcc
glpk-devel
java-1.7.0-openjdk-devel or java-1.6.0-openjdk-devel
libtool
swig
The installation command in Linux is:
sudo yum install gcc glpk-devel java-1.7.0-openjdk-devel libtool swig
Packages for Gentoo can be installed using the emerge command.
GLPK
Download the current version of GLPK source with
wget ftp://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
Unzip the archive with:
tar -xzf glpk-4.54.tar.gz
cd glpk-4.54
Configure with:
./configure
Make and install with:
make
make check
sudo make install
sudo ldconfig
Check the installation with
glpsol --version
Tools
For the next steps you will need a Java Development Kit (JDK) to be installed.
You can check the correct installation with the following commands:
$JAVA_HOME/bin/javac -version
java -version
If the JDK is missing refer to http://openjdk.java.net/install/ for installation instructions.
To build GLPK for Java you will need package SWIG (Simplified Wrapper and Interface Generator). You can check the installation with the following command:
swig -version
================GLPK for Java================
Download GLPK for Java from https://sourceforge.net/projects/glpk-java/files/.
Unzip the archive with:
tar -xzf glpk-java-1.0.36.tar.gz
cd glpk-java-1.0.36
Configure with:
./configure
Mac OS X has jni.h in a special path. You may want to specify this path in the parameters CPPFLAGS and SWIGFLAGS for the configure script, e.g.
./configure \
CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers \
SWIGFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
If libglpk.so (for linux) or libglpk.dylib (for mac) is in a special path you may specify this path using parameter LDFLAGS, e.g.
./configure LDFLAGS=-L/opt/lib
Make and install with:
make
make check
sudo make install
sudo ldconfig
Trivial example
In the example we will create a Java class which will write the GLPK version to the console.
With a text editor create a text file Test.java with the following content:
import org.gnu.glpk.GLPK;
public class Test {
public static void main(String[] args) {
System.out.println( GLPK.glp_version());
}
}
Windows
Compile the class
set CLASSPATH=C:Program Files\GLPK\glpk-4.54\w64\glpk-java.jar
"%JAVA_HOME%/bin/javac" Test.java
Run the class
path %PATH%;C:\Program Files\GLPK\glpk-4.54\w64
set CLASSPATH=C:\Program Files\GLPK\glpk-4.54\w64\glpk-java.jar;.
java -Djava.library.path="C:Program Files\GLPK\glpk-4.54\w64" Test
The output will be the GLPK version number, for example: 4.54.
Linux
Compile the class
javac -classpath /usr/local/share/java/glpk-java.jar Test.java
Run the class:
java -Djava.library.path=/usr/local/lib/jni \
-classpath /usr/local/share/java/glpk-java.jar:. \
Test