Presentation of G2DS

This applet, called G2DS for Graphical 2 Dimensional (linear programs) Solver, is useful for displaying and graphically solving linear programs with only 2 variables (x and y). Since the release of the new version (Version 2.0), this applet is also able to solve linear programs with two integer variables (which means that these variables are required to take integer values only).
The following explanations will help you use this applet.

Global remarks and comments
Components of a linear program
(Basic function) How to add/remove a constraint ?
(Basic function) How to add an objective function ?
Status area
Automatic zoom
Additional functions
New functions (available since the release of Version 2.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)".

To summarize, solving a linear program consists in optimizing a linear function over a convex set (polyhedron) which, in 2 dimensions, is a polygon (possibly empty or unbounded). In the following, 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. Let z* be the optimal value of a linear program, and let its objective function be [opt] dx + ey: 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.

(Basic function) 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 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 functions. 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 the constraints "x≥0" and "y≥0" can never be removed.

(Basic function) 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). 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 old one is lost.

Status area

The status area is located between the three upper lines of the applet and the area where the graphical representation of the problem is displayed. This status area, displayed in red, is used by the applet 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 applet, 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 applet automatically computes the most suitable zoom factor. You can be informed of the scaling factor used by the applet 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 functions

This section details the additional functions provided by this applet which are not absolutely necessary for a basic use. First, we describe the functions associated with buttons:

Other functions are available:

New functions (available since the release of Version 2.0)

This section details the new functions available in this applet since the release of the last version. 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 text area "Such that:" (which, as soon as you place the mouse cursor on it, displays the number of constraints) : 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 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!), then 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 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)!