Presentation of G2DS

This software, called G2DS for Graphical 2 Dimensional (linear programs) Solver, can be of use for displaying and graphically solving linear programs with only 2 variables (x and y).

There have been 3 public releases for this software since 2005: Version 1.0, Version 2.0, and Version 3.0 (which is precisely the current one). Before the release of Version 3.0, this software was written as a Java applet (a special class of Java programs, that are specifically designed to run inside web pages). Morever, since the release of Version 2.0 (included), this software is also able to solve linear programs with two integer variables (which means that these variables are required to take integer values only). Since the release of Version 3.0, this software is now written as a classical Java program.

The following explanations will help you use this software.

Global remarks and comments
Components of a linear program
How to run this software?
(Basic feature) How to add/remove a constraint?
(Basic feature) How to add an objective function?
Status area
Automatic zoom
Additional features
New features (available since the release of Version 2.0)
New new features (available since the release of Version 3.0)


Global remarks and comments

Components of a linear program

A linear program is defined by a set of linear constraints and a linear objective function. Here, we are only interested in linear programs having 2 variables, x and y, which means that any constraint can be written as « ax + by op c » (op being « ≥ », « = » or « ≤ ») and that the objective function can be written as « min/max (dx + ey) » (min for « minimize » and max for « maximize »), where the values a, b, c, d and e are constant.

To summarize, solving a linear program consists in optimizing (i.e., minimizing or maximizing) a linear function over a convex set (polyhedron) which, in 2 dimensions, is a polygon (possibly empty or unbounded). In what follows, this polygon will be refered to as the feasible polygon or constraints polygon. The « edges » of the polygon are called facets. A point belonging to two adjacent facets is called a basic point, or (with a slight abuse of terminology) a feasible basic solution. Let z* be the (finite) optimal value of a linear program (i.e., the best value that any of its feasible basic solutions can have), and let its objective function be [opt] (dx + ey) (where [opt] is equal to either min or max): then, the line dx + ey = z* is called the optimal line.

If we also require that the variables x and y only take integer values, then the obtained problem is called an integer linear program.

How to run this software?

In its current release, this software has been written as a Java program (and more precisely released as a JAR archive). As for any Java program, this means that, in order to run it, you will need to have a Java Virtual Machine (or JVM, in short) installed on your computer.

The basic command that needs to be executed in a console or terminal in order to run a Java program called G2DS and released as a JAR archive (which means that its full name is « G2DS.jar ») is the following one (where « java » is precisely the name of the program corresponding to the JVM, and where « > » is the symbol for the command prompt):

> java -jar G2DS.jar

However, this software has several options. On the one hand, one can choose its language (English or French), thanks to the first option: it suffices to use the option value « en » for English, and « fr » for French. If no value is provided (as this is the case in the previous example), then by default the software will launch in English.

The previous example is thus equivalent to the following call (in other words, in both cases, the software will launch in English):

> java -jar G2DS.jar en

If one wants to launch the software in French, then one just has to write:
> java -jar G2DS.jar fr

On the other hand, one can initialize the linear program to be solved by the software by means of a text file (which then contains a set of constraints and/or an objective function for this linear program). There are two options related to this possibility: the first one is the name of the text file containing these data, and the second one (which is not mandatory) is the symbol (character) used as a separator in this file (it will be denoted as sep in what follows, and it can be any character except « . »). Indeed, the format of such a file must be as follows:
It should be noticed, on the one hand, that the default value of the separator sep (i.e., the one that will be used if no other value is provided) is « , », and, on the other hand, that an example of such a file (representing a linear program with an objective function to be minimized as well as 3 constraints, and in which the separator is the default one), called « Test.txt », can be found
here.

In order to use this file when launching the software, one just has to write (note that we explicitly provide the separator « , »):

> java -jar G2DS.jar fr Test.txt ,

However, as the separator used in this file is actually the default one, one could simply write (note that, this time, we do not explicitly provide the separator « , » at the end of the line):

> java -jar G2DS.jar fr Test.txt

(Basic feature) How to add/remove a constraint?

Adding a constraint is very easy: just fill in the 3 text fields of the 3rd line. The first one contains the coefficient of x in the constraint, the second one the coefficient of y, and the last one the right-hand side of the constraint. Do not forget to select the inequality sign you need (« ≥ » or « ≤ »). Then, press the « Add » button and the constraint will be added to the list of constraints, i.e., the combo box containing all the constraints, while the feasible polygon will be automatically updated. There is another way to add a constraint, but we shall describe it in the section Additional features. If you press the « Cancel » button, you clear all the text fields of the 3rd line.

Some additional remarks:

To remove a constraint, select it in the list of constraints (2nd line), then press the « Remove » button. To remove all the constraints, press the « Clear all » button. Remember that, in the current release, the constraints « x ≥ 0 » and « y ≥ 0 » can never be removed.

(Basic feature) How to add an objective function?

Adding an objective function is almost the same as adding a new constraint. The 2 text fields of the 1st line respectively contain the coefficient of x and the coefficient of y in the objective function (and the 3 remarks of the previous section concerning the input procedure also apply in this case). Then, select « min » (for minimization), « max » (for maximization) or « none » (for adding no objective function), and press the « Set » button. The linear program will be solved automatically. Note that, each time you define a new objective function (by pressing « Set »), the former one is lost.

Status area

The status area is located between the three upper lines of the software and the area where the graphical representation of the problem is displayed. This status area, displayed in red, is used by the software to inform you of the current status of the linear program (number of feasible basic solutions, optimal value, information about integer solutions, etc.). Each time you launch the software, you can of course add as many constraints as you like (the only limit being the processing time!) and redefine the objective function as many times as you want. Each time a constraint is added or removed, the status area and the constraints polygon are automatically updated (the facets of the latter are the black lines). In the same way, when the objective function is defined/redefined, the optimal line is displayed on screen and the status is updated, except when the linear program has no optimal solution (in such a case, the information will be displayed in the status area anyway).

Automatic zoom

In order to draw the feasible polygon correctly, the software automatically computes the most suitable zoom factor. You can be informed of the scaling factor used by the software through the 2 values « Xmax » and « Ymax ». There are 10 points on both the x axis and the y axis, the distance between two consecutive points being constant. The 10th point on the x axis corresponds to the point with x = Xmax and the 10th on the y axis to the one with y = Ymax. The respective x coordinates of the other points on the x axis are then Xmax/10, 2*Xmax/10, etc.

Additional features

This section details the additional features provided by this software which are not absolutely necessary for a basic use. To begin with, we describe the features associated with buttons:

Other features are available:

New features (available since the release of Version 2.0)

This section details the new features available in this software since the release of Version 2.0. They provide the possibility of solving the linear program defined by the user as an integer linear program. More precisely, it will be solved as a linear program first, and then as an integer linear program. To enter this mode, you just have to click (with a simple click) on the underlined text area « Such that: » (which, as soon as you place the mouse cursor on it, actually displays the number of constraints, also underlined): then, the suffix « (i) » is added to this text area (to point out the fact that we have entered a mode where the integer solutions are displayed), and the information about the integer solutions of the linear program (number of integer solutions, unbounded feasible polygon, existence of an optimal integer solution, etc.) are now displayed in the status area. Moreover, the integer solutions contained in the display area are displayed as little black squares, and, if an objective function has been defined and if the optimal integer value is bounded (and provided that the optimal integer solution is contained in the display area!), this optimal integer solution is displayed as a little square with color (4).

In order to exit this mode (and to come back to the normal one), you just have to click once again (with a simple click) on the underlined text area « Such that: ». It should be noticed that the reason why the display area is defined with respect to the feasible basic solutions, and not with respect to the integer solutions (and, in particular, not with respect to the optimal integer solution), is that the optimal integer solution can be quite far from all the feasible basic solutions (and, so, from the optimal basic solution also). For instance, if we consider the following linear program: « maximize -3x+y, such that y ≥ 3/2, -x+20y ≤ 30, x ≥ 0 and y ≥ 0 », then the optimal basic solution is (x = 0, y = 3/2), while the optimal integer solution is (x = 10, y = 2)!

New new features (available since the release of Version 3.0)

This section details the new (new) features available in this software since the release of Version 3.0.

Firstly, if you click (with a simple click) on the underlined text area « Problem status: » (which, as soon as you place the mouse cursor on it, actually displays the number of facets, also underlined), then a first facet of the problem (among the ones that are neither « x = 0 » nor « y = 0 », if at least one such facet exists!) is selected (and thus will be of color (3)), and the corresponding constraint is also selected in the list of constraints (2nd line). If you click again (with a simple click) on this text area, another facet is selected instead (as well as the corresponding constraint), and then another one, and so on. If you click a sufficient number of times so that all the facets have been successively selected, then the process will start again from the first facet selected. Notice that adding or removing a constraint (and other events, such as asking the software to solve the linear program as an integer linear program) will make the software exit this mode (and then you will have to start the whole process again from the beginning, if needed).

Secondly, if you click (with a simple click) on the underlined text area that indicates the number of feasible basic solutions of the problem (1st line of the status area, in red), then a first feasible basic solution of the problem is selected (and thus will be of color (3)), and its coordinates are displayed in the text area « Basic solution displayed: » (in which, as long as this is not the case, is simply displayed « Basic solution displayed: none »). If you click again (with a simple click) on this text area, another feasible basic solution is selected instead (and, again, its coordinates are displayed in the text area « Basic solution displayed: »), and then another one, and so on. If you click a sufficient number of times so that all the feasible basic solutions have been successively selected, then the process will start again from the first feasible basic solution. Notice, here again, that adding or removing a constraint (and other events, such as asking the software to solve the linear program as an integer linear program) will make the software exit this mode (and then you will have to start the whole process again from the beginning, if needed).