Plotting bi-objective models

With gMOIP you can also make plots of the criterion space for bi-objective models (linear programming (LP), integer linear programming (ILP), or mixed integer linear programming (MILP)). This vignette gives examples on how to make plots of both the solution and criterion space.

First we load the package:

library(gMOIP)

Bi-objective models with two variables

We define a function for grouping plots of the solution and criterion space:

plotBiObj2D <- function(A, b, obj,
   type = rep("c", ncol(A)),
   crit = "max",
   faces = rep("c", ncol(A)),
   plotFaces = TRUE,
   plotFeasible = TRUE,
   plotOptimum = FALSE,
   labels = "numb",
   addTriangles = TRUE,
   addHull = TRUE)
{
   p1 <- plotPolytope(A, b, type = type, crit = crit, faces = faces, plotFaces = plotFaces,
                      plotFeasible = plotFeasible, plotOptimum = plotOptimum, labels = labels) + 
      ggplot2::ggtitle("Solution space")
   p2 <- plotCriterion2D(A, b, obj, type = type, crit = crit, addTriangles = addTriangles,
                         addHull = addHull, plotFeasible = plotFeasible, labels = labels) +
      ggplot2::ggtitle("Criterion space")
   gridExtra::grid.arrange(p1, p2, nrow = 1) 
}

Let us define the constraints:

A <- matrix(c(-3,2,2,4,9,10), ncol = 2, byrow = TRUE)
b <- c(3,27,90)

First let us have a look at a LP model:

obj <- matrix(
   c(7, -10, # first criterion
     -10, -10), # second criterion
   nrow = 2)
plotBiObj2D(A, b, obj, addTriangles = FALSE)

Note the non-dominated (Pareto) set consists of all supported extreme non-dominated points (illustrated with triangles) and the line segments between them.

ILP models with different criteria (maximize):

obj <- matrix(c(7, -10, -10, -10), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)))

obj <- matrix(c(3, -1, -2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)))

obj <- matrix(c(-7, -1, -5, 5), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)))

obj <- matrix(c(-1, -1, 2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)))

Note the non-dominated set consists of all points in black (with shape supported extreme:triangle, supported non-extreme:round, unsupported:round (not on the border)). The triangles drawn using the extreme non-dominated points illustrate areas where unsupported non-dominated points may be found. A point in the solution space is identified in the criterion space using the same number.

ILP models with different criteria (minimize):

obj <- matrix(c(7, -10, -10, -10), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)), crit = "min")

obj <- matrix(c(3, -1, -2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)), crit = "min")

obj <- matrix(c(-7, -1, -5, 5), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)), crit = "min")

obj <- matrix(c(-1, -1, 2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = rep("i", ncol(A)), crit = "min")

MILP model (\(x_1\) integer) with different criteria (maximize):

obj <- matrix(c(7, -10, -10, -10), nrow = 2)
plotBiObj2D(A, b, obj, type = c("i", "c"))

obj <- matrix(c(3, -1, -2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = c("i", "c"))

obj <- matrix(c(-7, -1, -5, 5), nrow = 2)
plotBiObj2D(A, b, obj, type = c("i", "c"))

obj <- matrix(c(-1, -1, 2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = c("i", "c"))

Note the solution space now consists to segments and hence the non-dominated set may consist of points and segments (open and closed). Note these segments are not highlighted in the current version of gMOIP.

MILP model (\(x_2\) integer) with different criteria (minimize):

## 
obj <- matrix(c(7, -10, -10, -10), nrow = 2)
plotBiObj2D(A, b, obj, type = c("c", "i"), crit = "min")

obj <- matrix(c(3, -1, -2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = c("c", "i"), crit = "min")

obj <- matrix(c(-7, -1, -5, 5), nrow = 2)
plotBiObj2D(A, b, obj, type = c("c", "i"), crit = "min")

obj <- matrix(c(-1, -1, 2, 2), nrow = 2)
plotBiObj2D(A, b, obj, type = c("c", "i"), crit = "min")

Bi-objective models with three variables

We define functions for plotting the solution and criterion space:

plotSol <- function(A, b, type = rep("c", ncol(A)),
                        faces = rep("c", ncol(A)),
                        plotFaces = TRUE, labels = "numb")
{
   loadView(v = view, close = F, zoom = 0.75)
   plotPolytope(A, b, type = type, faces = faces, labels = labels, plotFaces = plotFaces, 
                argsTitle3d = list(main = "Solution space"))
}

plotCrit <- function(A, b, obj, crit = "min", type = rep("c", ncol(A)), addTriangles = TRUE, 
                     labels = "numb") 
{
    plotCriterion2D(A, b, obj, type = type, crit = crit, addTriangles = addTriangles, 
                   labels = labels) + 
      ggplot2::ggtitle("Criterion space")
}

Four examples are given. A few plots of the solution space are made interactive to illustrate the functionality.

Example 1

We define the model \(\max \{cx | Ax \leq b\}\) (could also be minimized) with three variables:

We load the preferred view angle for the RGL window:

LP model (solution space):

LP model (criterion space):

ILP model (solution space):

ILP model (criterion space):

MILP model with variable 2 and 3 integer (solution space):

MILP model with variable 2 and 3 integer (criterion space):

MILP model with variable 1 and 3 integer (solution space):

MILP model with variable 1 and 3 integer (criterion space):

MILP model with variable 1 and 2 integer (solution space):

MILP model with variable 1 and 2 integer (criterion space):

MILP model with variable 1 integer (solution space):

MILP model with variable 1 integer (criterion space):

MILP model with variable 2 integer (solution space):

MILP model with variable 2 integer (criterion space):

MILP model with variable 3 integer (solution space - Interactive plot):

You must enable Javascript to view this page properly.

MILP model with variable 3 integer (criterion space):

Example 2

We define the model \(\max \{cx | Ax \leq b\}\) (could also be minimized) with three variables:

We load the preferred view angle for the RGL window:

LP model (solution space):

LP model (criterion space):

ILP model (solution space):

ILP model (criterion space):

MILP model with variable 2 and 3 integer (solution space):

MILP model with variable 2 and 3 integer (criterion space):

MILP model with variable 1 and 3 integer (solution space):

MILP model with variable 1 and 3 integer (criterion space):

MILP model with variable 1 and 2 integer (solution space):

MILP model with variable 1 and 2 integer (criterion space):

MILP model with variable 1 integer (solution space):

MILP model with variable 1 integer (criterion space):

MILP model with variable 2 integer (solution space - interactive plot):

You must enable Javascript to view this page properly.

MILP model with variable 2 integer (criterion space):

MILP model with variable 3 integer (solution space - Interactive plot):

MILP model with variable 3 integer (criterion space):

Example 3

We define the model \(\max \{cx | Ax \leq b\}\) (could also be minimized) with three variables:

We load the preferred view angle for the RGL window:

LP model (solution space):

LP model (criterion space):

ILP model (solution space):

ILP model (criterion space):

MILP model with variable 2 and 3 integer (solution space):

MILP model with variable 2 and 3 integer (criterion space):

MILP model with variable 1 and 3 integer (solution space):

MILP model with variable 1 and 3 integer (criterion space):

MILP model with variable 1 and 2 integer (solution space):

MILP model with variable 1 and 2 integer (criterion space):

MILP model with variable 1 integer (solution space):

MILP model with variable 1 integer (criterion space):

MILP model with variable 2 integer (solution space):

MILP model with variable 2 integer (criterion space):

MILP model with variable 3 integer (solution space - Interactive plot):

MILP model with variable 3 integer (criterion space):

Example 4

We define the model \(\max \{cx | Ax \leq b\}\) (could also be minimized) with three variables:

We load the preferred view angle for the RGL window:

LP model (solution space):

LP model (criterion space):

ILP model (solution space):

ILP model (criterion space):

MILP model with variable 2 and 3 integer (solution space):

MILP model with variable 2 and 3 integer (criterion space):

MILP model with variable 1 and 3 integer (solution space):

MILP model with variable 1 and 3 integer (criterion space):

MILP model with variable 1 and 2 integer (solution space):

MILP model with variable 1 and 2 integer (criterion space):

MILP model with variable 1 integer (solution space):

MILP model with variable 1 integer (criterion space):

MILP model with variable 2 integer (solution space):

MILP model with variable 2 integer (criterion space):

MILP model with variable 3 integer (solution space - Interactive plot):

MILP model with variable 3 integer (criterion space):