ArticleslgStudy

mathematics

OptimJ

OptimJ is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand OptimJ rather than just read about it. In short: OptimJ is an extension for Java 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.

Key takeaways

  • OptimJ belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect OptimJ to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of OptimJ from memory before moving on to harder problems.

Reference excerpt

OptimJ is an extension for Java 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, IBM ILOG CPLEX Optimization Studio.

Language concepts OptimJ combines concepts from object-oriented imperative languages with concepts from algebraic modeling languages 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.

Readers familiar with Java will notice a strong similarity with this language. Indeed, OptimJ is a conservative extension 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 will only allow linear constraints.

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.

In the map coloring example, decision variables were introduced together with the range of values they may take.

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.

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().

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 arrays or maps. In this example, the array age contains the age of persons, identified by their name:

The type int[String] denoting an array of int indexed by String. Accessing OptimJ arrays using the standard Java syntax:

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, as in:

or can be given in extensional definition, as in:

Here each of the entries length[i] is initialized with names[i].length().

Extended initialization

Tuples Tuples 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.

Tuple types and tuple values are both written between (: and :).

Ranges

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with OptimJ

Start with the simplest possible case. Write down what OptimJ claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to OptimJ before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about OptimJ ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of OptimJ

In research
OptimJ appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses OptimJ in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
OptimJ is common in secondary-school and first-year university syllabi. It links to neighbouring topics Discontinued programming languages, Mathematical modeling, Mathematical optimization software, so understanding it makes those chapters shorter.
In everyday life
Look for OptimJ outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study OptimJ in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what OptimJ means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain OptimJ out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is OptimJ in simple terms?

OptimJ is an extension for Java 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.

Why does OptimJ matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study OptimJ?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on OptimJ.

Tags

  • Discontinued programming languages
  • Mathematical modeling
  • Mathematical optimization software
  • Object-oriented programming languages
  • Programming languages created in 2006

Keep exploring