<s>
OptimJ	B-Application
is	O
an	O
extension	O
for	O
Java	B-Language
with	O
language	O
support	O
for	O
writing	O
optimization	O
models	O
and	O
abstractions	O
for	O
bulk	O
data	O
processing	O
.	O
</s>
<s>
OptimJ	B-Application
aims	O
at	O
providing	O
a	O
clear	O
and	O
concise	O
algebraic	O
notation	O
for	O
optimization	O
modeling	O
,	O
removing	O
compatibility	O
barriers	O
between	O
optimization	O
modeling	O
and	O
application	O
programming	O
tools	O
,	O
and	O
bringing	O
software	O
engineering	O
techniques	O
such	O
as	O
object-orientation	O
and	O
modern	O
IDE	O
support	O
to	O
optimization	O
experts	O
.	O
</s>
<s>
OptimJ	B-Application
models	O
are	O
directly	O
compatible	O
with	O
Java	B-Language
source	I-Language
code	I-Language
,	O
existing	O
Java	B-Language
libraries	O
such	O
as	O
database	O
access	O
,	O
Excel	O
connection	O
or	O
graphical	O
interfaces	O
.	O
</s>
<s>
OptimJ	B-Application
is	O
compatible	O
with	O
development	O
tools	O
such	O
as	O
Eclipse	O
,	O
CVS	O
,	O
JUnit	O
or	O
JavaDoc	O
.	O
</s>
<s>
OptimJ	B-Application
is	O
available	O
free	O
with	O
the	O
following	O
solvers	O
:	O
lp_solve	O
,	O
glpk	O
,	O
LP	O
or	O
MPS	O
file	O
formats	O
and	O
also	O
supports	O
the	O
following	O
commercial	O
solvers	O
:	O
MOSEK	B-Application
,	O
IBM	O
ILOG	O
CPLEX	O
Optimization	O
Studio	O
.	O
</s>
<s>
OptimJ	B-Application
combines	O
concepts	O
from	O
object-oriented	B-Language
imperative	B-Application
languages	I-Application
with	O
concepts	O
from	O
algebraic	B-Application
modeling	I-Application
languages	I-Application
for	O
optimization	O
problems	O
.	O
</s>
<s>
Here	O
we	O
will	O
review	O
the	O
optimization	O
concepts	O
added	O
to	O
Java	B-Language
,	O
starting	O
with	O
a	O
concrete	O
example	O
.	O
</s>
<s>
The	O
goal	O
of	O
a	O
map	B-Application
coloring	I-Application
problem	O
is	O
to	O
color	O
a	O
map	O
so	O
that	O
regions	O
sharing	O
a	O
common	O
border	O
have	O
different	O
colors	O
.	O
</s>
<s>
It	O
can	O
be	O
expressed	O
in	O
OptimJ	B-Application
as	O
follows	O
.	O
</s>
<s>
Readers	O
familiar	O
with	O
Java	B-Language
will	O
notice	O
a	O
strong	O
similarity	O
with	O
this	O
language	O
.	O
</s>
<s>
Indeed	O
,	O
OptimJ	B-Application
is	O
a	O
conservative	O
extension	O
of	O
Java	B-Language
:	O
every	O
valid	O
Java	B-Language
program	O
is	O
also	O
a	O
valid	O
OptimJ	B-Application
program	O
and	O
has	O
the	O
same	O
behavior	O
.	O
</s>
<s>
This	O
map	B-Application
coloring	I-Application
example	O
also	O
shows	O
features	O
specific	O
to	O
optimization	O
that	O
have	O
no	O
direct	O
equivalent	O
in	O
Java	B-Language
,	O
introduced	O
by	O
the	O
keywords	O
model	O
,	O
var	O
,	O
constraints	O
.	O
</s>
<s>
A	O
model	O
is	O
an	O
extension	O
of	O
a	O
Java	B-Language
class	O
that	O
can	O
contain	O
not	O
only	O
fields	O
and	O
methods	O
but	O
also	O
constraints	O
and	O
an	O
objective	O
function	O
.	O
</s>
<s>
The	O
capabilities	O
of	O
the	O
solver	O
will	O
determine	O
what	O
kind	O
of	O
constraints	O
can	O
be	O
expressed	O
in	O
the	O
model	O
,	O
for	O
instance	O
a	O
linear	O
solver	O
such	O
as	O
lp	B-Algorithm
solve	I-Algorithm
will	O
only	O
allow	O
linear	O
constraints	O
.	O
</s>
<s>
Imperative	B-Application
languages	I-Application
such	O
as	O
Java	B-Language
provide	O
a	O
notion	O
of	O
imperative	B-Application
variables	O
,	O
which	O
basically	O
represent	O
memory	O
locations	O
that	O
can	O
be	O
written	O
to	O
and	O
read	O
from	O
.	O
</s>
<s>
OptimJ	B-Application
also	O
introduces	O
the	O
notion	O
of	O
a	O
decision	O
variable	O
,	O
which	O
basically	O
represents	O
an	O
unknown	O
quantity	O
whose	O
value	O
one	O
is	O
searching	O
.	O
</s>
<s>
The	O
term	O
"	O
decision	O
variable	O
"	O
comes	O
from	O
the	O
optimization	O
community	O
,	O
but	O
decision	O
variables	O
in	O
OptimJ	B-Application
are	O
the	O
same	O
concept	O
as	O
logical	O
variables	O
in	O
logical	O
languages	O
such	O
as	O
Prolog	O
.	O
</s>
<s>
There	O
is	O
a	O
var	O
type	O
for	O
each	O
possible	O
Java	B-Language
type	O
.	O
</s>
<s>
In	O
the	O
map	B-Application
coloring	I-Application
example	O
,	O
decision	O
variables	O
were	O
introduced	O
together	O
with	O
the	O
range	O
of	O
values	O
they	O
may	O
take	O
.	O
</s>
<s>
A	O
constraint	O
can	O
be	O
any	O
Java	B-Language
boolean	O
expression	O
involving	O
decision	O
variables	O
.	O
</s>
<s>
In	O
the	O
map	B-Application
coloring	I-Application
example	O
,	O
this	O
set	O
of	O
constraints	O
states	O
that	O
in	O
any	O
solution	O
to	O
the	O
map	B-Application
coloring	I-Application
problem	O
,	O
the	O
color	O
of	O
Belgium	O
must	O
be	O
different	O
from	O
the	O
color	O
of	O
Germany	O
,	O
and	O
the	O
color	O
of	O
Germany	O
must	O
be	O
different	O
from	O
the	O
color	O
of	O
Denmark	O
.	O
</s>
<s>
The	O
operator	O
!=	O
is	O
the	O
standard	O
Java	B-Language
not-equal	O
operator	O
.	O
</s>
<s>
Assuming	O
that	O
the	O
array	O
countries	O
contains	O
belgium	O
,	O
germany	O
and	O
denmark	O
,	O
and	O
that	O
the	O
predicate	O
isNeighbor	O
returns	O
true	O
for	O
the	O
couples	O
(	O
Belgium	O
,	O
Germany	O
)	O
and	O
(	O
Germany	O
,	O
Denmark	O
)	O
,	O
then	O
this	O
code	O
is	O
equivalent	O
to	O
the	O
constraints	O
block	O
of	O
the	O
original	O
map	B-Application
coloring	I-Application
example	O
.	O
</s>
<s>
The	O
generalist	O
concepts	O
added	O
to	O
Java	B-Language
by	O
OptimJ	B-Application
make	O
the	O
expression	O
of	O
OR	O
models	O
easier	O
or	O
more	O
concise	O
.	O
</s>
<s>
While	O
Java	B-Language
arrays	O
can	O
only	O
be	O
indexed	O
by	O
0-based	O
integers	O
,	O
OptimJ	B-Application
arrays	O
can	O
be	O
indexed	O
by	O
values	O
of	O
any	O
type	O
.	O
</s>
<s>
Such	O
arrays	O
are	O
typically	O
called	O
associative	B-Application
arrays	I-Application
or	O
maps	O
.	O
</s>
<s>
Accessing	O
OptimJ	B-Application
arrays	O
using	O
the	O
standard	O
Java	B-Language
syntax	O
:	O
</s>
<s>
Traditionally	O
,	O
associative	B-Application
arrays	I-Application
are	O
heavily	O
used	O
in	O
the	O
expression	O
of	O
optimization	O
problems	O
.	O
</s>
<s>
OptimJ	B-Application
associative	B-Application
arrays	I-Application
are	O
very	O
handy	O
when	O
associated	O
to	O
their	O
specific	O
initialization	O
syntax	O
.	O
</s>
<s>
or	O
can	O
be	O
given	O
in	O
extensional	B-Architecture
definition	I-Architecture
,	O
as	O
in	O
:	O
</s>
<s>
Tuples	B-Application
are	O
ubiquitous	O
in	O
computing	O
,	O
but	O
absent	O
from	O
most	O
mainstream	O
languages	O
including	O
Java	B-Language
.	O
</s>
<s>
OptimJ	B-Application
provides	O
a	O
notion	O
of	O
tuple	B-Application
at	O
the	O
language	O
level	O
that	O
can	O
be	O
very	O
useful	O
as	O
indexes	O
in	O
combination	O
with	O
associative	B-Application
arrays	I-Application
.	O
</s>
<s>
Tuple	B-Application
types	O
and	O
tuple	B-Application
values	O
are	O
both	O
written	O
between	O
(	O
:	O
and	O
:	O
)	O
.	O
</s>
<s>
Comprehensions	O
,	O
also	O
called	O
aggregates	O
operations	O
or	O
reductions	O
,	O
are	O
OptimJ	B-Application
expressions	O
that	O
extend	O
a	O
given	O
binary	O
operation	O
over	O
a	O
collection	O
of	O
values	O
.	O
</s>
<s>
This	O
construction	O
is	O
very	O
similar	O
to	O
the	O
big-sigma	O
summation	O
notation	O
used	O
in	O
mathematics	O
,	O
with	O
a	O
syntax	O
compatible	O
with	O
the	O
Java	B-Language
language	I-Language
.	O
</s>
<s>
Comprehension	B-Language
expressions	O
can	O
have	O
an	O
arbitrary	O
expression	O
as	O
target	O
,	O
as	O
in	O
:	O
</s>
<s>
Comprehension	B-Language
need	O
not	O
apply	O
only	O
to	O
numeric	O
values	O
.	O
</s>
<s>
Set	O
or	O
multiset-building	O
comprehensions	O
,	O
especially	O
in	O
combination	O
with	O
tuples	B-Application
of	O
strings	O
,	O
make	O
it	O
possible	O
to	O
express	O
queries	O
very	O
similar	O
to	O
SQL	O
database	O
queries	O
:	O
</s>
<s>
In	O
the	O
context	O
of	O
optimization	O
models	O
,	O
comprehension	B-Language
expressions	O
provide	O
a	O
concise	O
and	O
expressive	O
way	O
to	O
pre-process	O
and	O
clean	O
the	O
input	O
data	O
,	O
and	O
format	O
the	O
output	O
data	O
.	O
</s>
<s>
OptimJ	B-Application
is	O
available	O
as	O
an	O
Eclipse	O
plug-in	O
.	O
</s>
<s>
The	O
compiler	O
implements	O
a	O
source-to-source	B-Language
translation	I-Language
from	O
OptimJ	B-Application
to	O
standard	O
Java	B-Language
,	O
thus	O
providing	O
immediate	O
compatibility	O
with	O
most	O
development	O
tools	O
of	O
the	O
Java	B-Language
ecosystem	O
.	O
</s>
<s>
Since	O
the	O
OptimJ	B-Application
compiler	O
knows	O
about	O
the	O
structure	O
of	O
all	O
data	O
used	O
in	O
models	O
,	O
it	O
is	O
able	O
to	O
generate	O
a	O
structured	O
graphical	O
view	O
of	O
this	O
data	O
at	O
compile-time	O
.	O
</s>
<s>
This	O
is	O
especially	O
relevant	O
in	O
the	O
case	O
of	O
associative	B-Application
arrays	I-Application
where	O
the	O
compiler	O
knows	O
the	O
collections	O
used	O
for	O
indexing	O
the	O
various	O
dimensions	O
.	O
</s>
<s>
The	O
compiler-generated	O
OptimJ	B-Application
GUI	O
saves	O
the	O
OR	O
expert	O
from	O
writing	O
all	O
the	O
glue	O
code	O
required	O
when	O
mapping	O
graphical	O
libraries	O
to	O
data	O
.	O
</s>
<s>
Another	O
part	O
of	O
the	O
OptimJ	B-Application
GUI	O
reports	O
in	O
real	O
time	O
performance	O
statistics	O
from	O
the	O
solver	O
.	O
</s>
<s>
OptimJ	B-Application
is	O
available	O
for	O
free	O
with	O
the	O
following	O
solvers	O
lp_solve	O
,	O
glpk	O
,	O
LP	O
or	O
MPS	O
file	O
formats	O
and	O
also	O
supports	O
the	O
following	O
commercial	O
solvers	O
:	O
Mosek	B-Application
,	O
IBM	O
ILOG	O
CPLEX	O
Optimization	O
Studio	O
.	O
</s>
