HOME

TheInfoList



OR:

OptimJ is an extension for
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
with language support for writing optimization models and abstractions for bulk data processing. The extensions and the proprietary product implementing the extensions were developed by Ateji which went out of business in September 2011. OptimJ aims at providing a clear and concise algebraic notation for optimization modeling, removing compatibility barriers between optimization modeling and application programming tools, and bringing software engineering techniques such as object-orientation and modern IDE support to optimization experts. OptimJ models are directly compatible with Java source code, existing Java libraries such as database access, Excel connection or graphical interfaces. OptimJ is compatible with development tools such as Eclipse, CVS, JUnit or JavaDoc. OptimJ is available free with the following solvers: lp_solve, glpk, LP or MPS file formats and also supports the following commercial solvers:
MOSEK MOSEK is a software package for the solution of linear, mixed-integer linear, quadratic, mixed-integer quadratic, quadratically constraint, conic and convex nonlinear mathematical optimization problems. The applicability of the solver varies wide ...
, IBM ILOG CPLEX Optimization Studio.


Language concepts

OptimJ combines concepts from object-oriented imperative languages with concepts from
algebraic modeling language Algebraic modeling languages (AML) are high-level computer programming languages for describing and solving high complexity problems for large scale mathematical computation (i.e. large scale optimization type problems). One particular advantage of ...
s for optimization problems. Here we will review the optimization concepts added to Java, starting with a concrete example.


The example of map coloring

The goal of a map coloring problem is to color a map so that regions sharing a common border have different colors. It can be expressed in OptimJ as follows. package examples; // a simple model for the map-coloring problem public model SimpleColoring solver lpsolve Readers familiar with Java will notice a strong similarity with this language. Indeed, OptimJ is a
conservative extension In mathematical logic, a conservative extension is a supertheory of a theory which is often convenient for proving theorems, but proves no new theorems about the language of the original theory. Similarly, a non-conservative extension is a superthe ...
of Java: every valid Java program is also a valid OptimJ program and has the same behavior. This map coloring example also shows features specific to optimization that have no direct equivalent in Java, introduced by the keywords model, var, constraints.


OR-specific concepts


Models

A model is an extension of a Java class that can contain not only fields and methods but also constraints and an objective function. It is introduced by the model keyword and follows the same rules as class declarations. A non-abstract model must be linked to a solver, introduced by the keyword solver. The capabilities of the solver will determine what kind of constraints can be expressed in the model, for instance a linear solver such as
lp solve Linear programming (LP), also called linear optimization, is a method to achieve the best outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements are represented by linear relationships. Linear programming i ...
will only allow linear constraints. public model SimpleColoring solver lpsolve


Decision variables

Imperative languages such as Java provide a notion of imperative variables, which basically represent memory locations that can be written to and read from. OptimJ also introduces the notion of a decision variable, which basically represents an unknown quantity whose value one is searching. A solution to an optimization problem is a set of values for all its decision variables that respects the constraints of the problem—without decision variables, it would not possible to express optimization problems. The term "decision variable" comes from the optimization community, but decision variables in OptimJ are the same concept as logical variables in logical languages such as Prolog. Decision variables have special types introduced by the keyword var. There is a var type for each possible Java type. // a var type for a Java primitive type var int x; // a var type for a user-defined class var MyClass y; In the map coloring example, decision variables were introduced together with the range of values they may take. var int germany in 1 .. nbColors; This is just a shorthand equivalent to putting a constraint on the variable.


Constraints

Constraints express conditions that must be true in any solution of the problem. A constraint can be any Java boolean expression involving decision variables. In the map coloring example, this set of constraints states that in any solution to the map coloring problem, the color of Belgium must be different from the color of Germany, and the color of Germany must be different from the color of Denmark. constraints The operator != is the standard Java not-equal operator. Constraints typically come in batches and can be quantified with the forall operator. For instance, instead of listing all countries and their neighbors explicitly in the source code, one may have an array of countries, an array of decision variables representing the color of each country, and an array boolean[][] neighboring or a predicate (a boolean function) boolean isNeighbor(). constraints Country c1 : countries is a generator: it iterates c1 over all the values in the collection countries. :isNeighbor(c1,c2) is a filter: it keeps only the generated values for which the predicate is true (the symbol : may be read as "if"). Assuming that the array countries contains belgium, germany and denmark, and that the predicate isNeighbor returns true for the couples (Belgium , Germany) and (Germany, Denmark), then this code is equivalent to the constraints block of the original map coloring example.


Objectives

Optionally, when a model describes an optimization problem, an objective function to be minimized or maximized can be stated in the model.


Generalist concepts

Generalist concepts are programming concepts that are not specific to OR problems and would make sense for any kind of application development. The generalist concepts added to Java by OptimJ make the expression of OR models easier or more concise. They are often present in older modeling languages and thus provide OR experts with a familiar way of expressing their models.


Associative arrays

While Java arrays can only be indexed by 0-based integers, OptimJ arrays can be indexed by values of any type. Such arrays are typically called
associative array In computer science, an associative array, map, symbol table, or dictionary is an abstract data type that stores a collection of (key, value) pairs, such that each possible key appears at most once in the collection. In mathematical terms an as ...
s or maps. In this example, the array age contains the age of persons, identified by their name: int
tring Tring is a market town and civil parish in the Borough of Dacorum, Hertfordshire, England. It is situated in a gap passing through the Chiltern Hills, classed as an Area of Outstanding Natural Beauty, from Central London. Tring is linked to ...
age;
The type int
tring Tring is a market town and civil parish in the Borough of Dacorum, Hertfordshire, England. It is situated in a gap passing through the Chiltern Hills, classed as an Area of Outstanding Natural Beauty, from Central London. Tring is linked to ...
/code> denoting an array of int indexed by String. Accessing OptimJ arrays using the standard Java syntax: age Stephan"= 37; x = age Lynda" Traditionally, associative arrays are heavily used in the expression of optimization problems. OptimJ associative arrays are very handy when associated to their specific initialization syntax. Initial values can be given in
intensional definition In logic, extensional and intensional definitions are two key ways in which the objects, concepts, or referents a term refers to can be defined. They give meaning or denotation to a term. Intensional definition An intensional definition gives ...
, as in: int
tring Tring is a market town and civil parish in the Borough of Dacorum, Hertfordshire, England. It is situated in a gap passing through the Chiltern Hills, classed as an Area of Outstanding Natural Beauty, from Central London. Tring is linked to ...
age = ;
or can be given in
extensional definition In logic, extensional and intensional definitions are two key ways in which the objects, concepts, or referents a term refers to can be defined. They give meaning or denotation to a term. Intensional definition An intensional definition gives m ...
, as in: int
tring Tring is a market town and civil parish in the Borough of Dacorum, Hertfordshire, England. It is situated in a gap passing through the Chiltern Hills, classed as an Area of Outstanding Natural Beauty, from Central London. Tring is linked to ...
length tring name : names= name.length();
Here each of the entries length /code> is initialized with names length().


Extended initialization


Tuples

Tuple In mathematics, a tuple is a finite ordered list (sequence) of elements. An -tuple is a sequence (or ordered list) of elements, where is a non-negative integer. There is only one 0-tuple, referred to as ''the empty tuple''. An -tuple is defi ...
s are ubiquitous in computing, but absent from most mainstream languages including Java. OptimJ provides a notion of tuple at the language level that can be very useful as indexes in combination with associative arrays. (: int, String :) myTuple = new (: 3, "Three" :); String s = myTuple#1; Tuple types and tuple values are both written between (: and :).


Ranges


Comprehensions

Comprehensions, also called aggregates operations or reductions, are OptimJ expressions that extend a given binary operation over a collection of values. A common example is the sum: // the sum of all integers from 1 to 10 int k = sum ; This construction is very similar to the big-sigma
summation In mathematics, summation is the addition of a sequence of any kind of numbers, called ''addends'' or ''summands''; the result is their ''sum'' or ''total''. Beside numbers, other types of values can be summed as well: functions, vectors, mat ...
notation used in mathematics, with a syntax compatible with the Java language. Comprehensions can also be used to build collections, such as lists, sets, multisets or maps: // the set of all integers from 1 to 10 HashSet s = `hashSet(); Comprehension expressions can have an arbitrary expression as target, as in: // the sum of all squares of integers from 1 to 10 int k = sum ; They can also have an arbitrary number of generators and filters: // the sum of all f(i,j), for 0<=i<10, 1<=j<=10 and i!=j int k = sum Comprehension need not apply only to numeric values. Set or multiset-building comprehensions, especially in combination with tuples of strings, make it possible to express queries very similar to SQL database queries: // select name from persons where age > 18 `multiSet() In the context of optimization models, comprehension expressions provide a concise and expressive way to pre-process and clean the input data, and format the output data.


Development environment

OptimJ is available as an Eclipse plug-in. The compiler implements a source-to-source translation from OptimJ to standard Java, thus providing immediate compatibility with most development tools of the Java ecosystem.


OptimJ GUI and Rapid Prototyping

Since the OptimJ compiler knows about the structure of all data used in models, it is able to generate a structured graphical view of this data at compile-time. This is especially relevant in the case of associative arrays where the compiler knows the collections used for indexing the various dimensions. The basic graphical view generated by the compiler is reminiscent of an
OLAP cube An OLAP cube is a multi-dimensional array of data. Online analytical processing (OLAP) is a computer-based technique of analyzing data to look for insights. The term ''cube'' here refers to a multi-dimensional dataset, which is also sometimes ca ...
. It can then be customized in many different ways, from simple coloring up to providing new widgets for displaying data elements. The compiler-generated OptimJ GUI saves the OR expert from writing all the glue code required when mapping graphical libraries to data. It enables rapid prototyping, by providing immediate visual hints about the structure of data. Another part of the OptimJ GUI reports in real time performance statistics from the solver. This information can be used for understanding performance problems and improving solving time. At this time, it is available only for lp_solve.


Supported solvers

OptimJ is available for free with the following solvers lp_solve, glpk, LP or MPS file formats and also supports the following commercial solvers: Mosek, IBM ILOG CPLEX Optimization Studio.


External links


Object-oriented Modeling with OptimJThe OptimJ language manual


References


Rapid application development with OPTIMJ, a practitioner's experience report. David Gravot, Patrick Viry. EURO 2010 (Lisbon)OptimJ used in an optimization model for mixed-model assembly lines, University of MünsterOptimJ used in an Approximate Subgame-Perfect Equilibrium Computation Technique for Repeated Games, Laval University
{{Mathematical optimization software Object-oriented programming languages Mathematical optimization software Mathematical modeling Discontinued programming languages Programming languages created in 2006