OptimJ GUI |
A graphical user interface for LP/MIP solvers
OptimJ GUI is a free graphical user interface (GUI) for LP/MIP solvers currently supporting lp_solve (more target solvers to come). Its main features are:
OptimJ GUI will help you:
Operating modesOptimJ GUI can operate either as a stand-alone Java tool or in combination with OptimJ. When used as a stand-alone tool, OptimJ GUI can display in real time all the lp_solve internal state. Simply add one line to your existing Java code: When used in combination with OptimJ, OptimJ GUI will additionally display the model structure in terms of the data structures defined in the OptimJ source. It can display both decision variables (the unknown of the model) and programming variables (the parameters of the model). OverviewThis page is organized as follows:
This is a beta version. This documentation refers to the RC2 beta version of OptimJ GUI. APIs are subject to change. Comments and suggestions for improvements are welcome in the OptimJ GUI forum. While the current version only works with lp_solve, OptimJ GUI will progressively be targeted to all solvers supported by OptimJ. Part 1: Using OptimJ GUI as a stand-alone toolWhen used as a stand-alone tool, OptimJ GUI provides:
If you're familiar with lp_solve, you'll notice that OptimJ GUI bears some ressemblance with LPSolve IDE. There are however major differences:
Just one lineIn order to use OptimJ GUI, the only change that is required to your code is the addition of a single line: OptimJ GUI comes with a set of samples that contains examples of code for running and displaying models written in lp or mps file formats. If you're not familiar with Java, simply copy-and-paste these samples. Main windowThe top part of the GUI window is a "control panel" that presents an overview of the model and the solver state:
![]() In the bottom part of the window, the first three tabs relate to the lp_solve state:
Debugging and tuning a modelThe 'Run' tab displays in real-time:
Visualizing the evolution of the objective function is helpful in understanding where solving time is spent. As an example, on a specific model, if the branch-and-bound algorithm does not show any progress after a first solution, this may be a hint that this first solution is a good candidate and that there is no need waiting for a provably optimal solution. The 'Parameters' tab provides an interactive way to experiment with various settings, such as:
For a given model, a good choice of settings can have a tremendous impact on performance.
The 'Matrix data' tab displays in real-time the model structure as seen by the solver:
Part 2: Using OptimJ GUI with OptimJ modelsOptimJ is an extension of the Java programming language with language support for writing optimization models and powerful abstractions for bulk data processing. All standard Java libraries and tools are directly available. The language is supported by programming tools under the Eclipse environment. When used in combination with OptimJ, the GUI will display a new tab called Model Data. This tab displays the model in terms of the data structures defined in the OptimJ source. It can display variables (the unknown of the model) and programming variables (the parameters of the model). A running example: the transportation problemOur running example will be the transportation model, a canonical example that appears in the first pages of most textbook about optimization techniques. The transportation problem consists in determining the quantity of product to be supplied from each factory to each customer in order to minimize the total cost. In the following, we will focus on the transportation cost from a factory to customer. We model this information with a 2-dimensional associative array. Here is how this associative array is declared in OptimJ (code samples on light yellow background indicate OptimJ code) : The OptimJ compiler will then use its knowledge of the structure of the associative array cost to generate a default table viewer for it. How to get the code samples Any example of this tutorial may be downloaded here (2Mo). To install this sample project in your Eclipse workspace, follow these steps:
In addition to the examples you will find all the libraries required to launch the GUI:
You will need a valid OptimJ license for compiling this model. Evaluation licenses can be obtained here. OptimJ generates a default viewer for each modelWhen OptimJ compiles a model, it has a full understanding of all its structure. The compiler uses this information to generate default viewers for all fields declared in the model. We will see later how to customize these default viewers. All tables are grouped together in a type named DefaultViewersContainer (an implicit member class of the model). For exemple, the array cost defined previously is displayed as a two dimensional structure indexed by factories (left) and customers (top).
Once the code is generated, it can be used directly in your application. Here is how to use the default container for the transportation model.
In constrast, using a visualization API may require 100's of lines of code for the same result. Here, the bulk of the work is done by the OptimJ compiler at compile time. Now let's see how to customize default viewers. Customizing viewersThe generated default viewer container can be customized in arbitrary ways with little additional code. First, define an OptimJ class that extends DefaultViewersContainer:
In order to use this customized viewer container, instantiate CustomizedViewersContainer instead of the default viewers: We are now ready to customize the display. How to customize the displayed textBelow is the result we want to obtain, with a $ sign displayed in front of each number:
We are going to enhance the class CustomizedViewersContainer to obtain this result: Relationship between model data and their table viewers
Each table viewer has a number of properties. Property element handles everything related to the display of internal cells: element itself has a property texter that controls the text contents of a cell: The full list of viewer properties is given in the appendix. The type of the texter is Texter2 (since array cost has two dimensions), an interface that can be instanciated by providing a method How to colorize table cellsHere we will color in red cells that have a cost of more than $15. By default, each cell of the table is an SWT label. The decorator property provides a hook for customizing this label. Within the Here is the resulting display:
Technical note: Labels can be reused by the display, this means that the decorate method cannot assume that the label is in a particular default state. The How to use other SWT controlsThe creator property can be used to provide an arbitrary SWT Control. This makes it possible to display not only labels, but also combos, buttons, canvas, lists, etc. You can even embed arbitrary controls such as pie-charts or bar-charts using any SWT-compatible charts library. In the following example, each cell is displayed as an SWT Here's how to use the creator property for this example: Below are two examples made using the creator property with standard Java visualization components. How to customize indexesIndexes are the cells that appear as row and column headers. The OptimJ GUI generates an arbitrary default layout when multiple indexes are present. For example, table cost is displayed with factories of the left (y-dimension) and customers on the top (x-dimension). It is possible to reorder indexes differently. We will see here how to customize indexes in order to bring factories on the top and customers on the left. Each dimension of an array is represented by an index. Indexes are used for:
In other words, an index can be used individually to change its properties, and also in combination with other indexes in order to configure the table layout. Each array dimension has a corresponding index. Getting back to our array cost,
Note that indexes are generated not only for arrays (legacy or associative), but also for all collections. For instance, java.lang.Set and java.lang.List are considered as one-dimensional structures for display purposes. Customizing the table layout The two following examples change the position of the indexes inside the table and then reorganize the display of table cost. Property xIndexes of a table contains indexes that will be displayed on the top of the table. The order is important: the first index will be the outer most. Similarly, the property yIndexes contains indexes displayed on the left. This code puts customers (index0) on the X axis, and factories (index1) on the Y axis.
The screenshots below show all these combinations:
Customizing index cells Like element cells, index cells have a texter property for customizing the displayed text. For example, here is how to customize the text associated for a factory: Other table propertiesThere are many more properties for customizing viewers, the full list is given in the appendix. By default, the name of the table cost is 'cost: double[Customer][Factory]'. You can change it with the following code: Yet other properties define the size of cells: Specifiying the viewers to be displayedBy default, viewers are displayed for all fields of a model that are not private and not static, including fields inherited from the super-types (shadowed fields are excluded). If the type of a given field is array, associative array, Collection or Map, it has its own viewer. Otherwise the field is displayed in a special table named scalars. For a large model, this can amount to an information overhead, especially if you're designing a prototype to be shown to the client. In order to show only the relevant information, the viewer property makes it possible to specify the set of viewers that will be displayed. The following code states that only the fields cost and quantity should be displayed. Reusing propertiesQuite often, you'll want to set identical values to many different properties, such as having all cell text displayed with the same font. You can do this simply by assigning the same object to different properties. For instance, here is how you would reuse the same texter for all indexes:
Advanced featuresCallbacksOptimJ GUI uses callbacks for displaying solver information in real time. These callbacks may interfere with those in your code. This is due to the lp_solve API design: registering a callbacks removes any previously registered one, without notice. There is no simple solution at this moment, the safest approach is to disable your callbacks while using OptimJ GUI. Detecting the termination of solve()lp_solve callbacks do not send events for the start and the end of the solve method. As a result, some features such as the tabs displaying the current solver state may not work properly (the EXITED tab will never be highlighted). If you need to know when and why the solve() method terminated, OptimJ GUI provides a wrapper that sends the appropriate events. Here is how to use it: Starting in running stateBy default, OptimJ GUI starts in paused state (you'll need to click 'Run' before anything happens). You can ask the GUI to start in running mode by specifying an additional parameter to the Here are all versions of the AppendixTable propertiesThe following image shows a table and its properties. Additionally, all cells have the following properties:
Type hierarchy and propertiesBelow is an exhaustive list of all classes and fields relevant for using OptimJ GUI. Except for the classes generated as part of the model, they all belong to the package
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Customer Quotes
We're going to deploy OptimJ capabilities for our ongoing Java-based projects to close a gap between optimization engines and Java applications.
With OptimJ you get the expressiveness of OPL™ with the integrability and flexibility of Ilog Concert™ -- the best of both worlds.
Integrating optimization projects in a Java environment becomes a breeze using the Eclipse IDE, shortening project development times up to 50%.
OptimJ made it easy to use results from different solvers and combine exact methods with metaheuristics coded in Java, for solving complex industrial problems.
I used OptimJ to implement a model for production planning in a polystyrene factory.
We've succesfully applied OptimJ to improve an existing software application developed in one of our past numerical optimization projects.
Using OptimJ enabled a rapid development and integration of optimization models in Java-based applications.










