goalp {goalp}R Documentation

Solves a (linear) goal programming problem

Description

Given a set of equations representing goals of a linear goal programming problem, it finds the optimal solution.

Usage

goalp(
  eqs,
  A = NULL,
  m = NULL,
  b = NULL,
  w = NULL,
  p = NULL,
  varType = NULL,
  normW = FALSE,
  silent = FALSE
)

Arguments

eqs

Character vector describing a set of linear equations. The vector can either contain a single element with one equation per line, or multiple elements, each with a single equation. Equations must be valid R expressions (see details).

A

Numeric matrix with the coefficients of the variables. One row per equation, one column per variable. Columns can be named according to the variables they correspond to. Rows can be named for their corresponding goals. Ignored if argument eqs is provided.

m

Character vector with the relationship between the left and right-hand side of the goals. It can be any of =, ==, <=, >=. = allows for positive (excess) and negative (lack) deviations. == do not allow any deviation, enforcing fulfillment of the goal. <= automatically assigns a weight equal to zero to the negative (lack) deviation. >= automatically assigns a weight equal to zero to the positive (excess) deviation.

b

Numeric vector with the values on the right hand side of the goals. Ignored if argument eqs is provided.

w

Numeric matrix with the weights associated to the deviations from each goal. It should have as many rows as goals, and two columns: the first column corresponding to the weight of the positive deviation (excess), and the second column corresponding to the weight of the negative deviation (lack). This argument is ignored if eqs is provided. If omitted and eqs is not provided either, default weights are dependent on the type of goal, as follows.

  • =: Positive and negative deviations are assigned equal weights of 1.

  • ==: Positive and negative deviations are assigned equal weights of NA, as these deviations will be excluded from the problem, i.e. the goal will be enforced.

  • >=: Positive deviation is assigned a weight of 0, so it does not influence the objective function (and therefore the solution to the problem). The negative deviation is assigned a weight of 1, but if manually set to NA, then the inequality is enforced.

  • <=: Negative deviation is assigned a weight of 0, so it does not influence the objective function (and therefore the solution to the problem). The positive deviation is assigned a weight of 1, but if manually set to NA, then the inequality is enforced.

p

Numeric matrix indicating the priority of each deviation under a lexicographic approach. Lower numbers represent higher priority (e.g. from lower to higher priority: 1, 2, 3, ...). It must have as many rows as goals, and two columns. This argument is ignored if eqs is provided. If omitted and not provided in eqs either, default priorities are dependent on the type of goal, as follows.

  • =: Positive and negative deviations are assigned equal priority of 1.

  • ==: Positive and negative deviations are assigned equal priority of NA, as these deviations will be excluded from the problem, i.e. the goal will be enforced.

  • >=: Positive deviation is assigned a priority of +Inf, making it irrelevant. The negative deviation is assigned a priority of 1.

  • <=: Negative deviation is assigned a priority of +Inf, making it irrelevant. The positive deviation is assigned a priority of 1.

varType

Named character vector. Defines the type of each variable. It can be defined as c(x1="int", x2="cont"). Omitted variables are assumed to be integer. Each element can be either "continuous" (i.e. non-negative real values), "integer" (i.e. non-negative natural values), or "binary" (i.e. only take values 0 or 1). Using only the first letters is accepted too. If omitted, all variables are assumed to be integer.

normW

Logical. TRUE to scale the weights by the inverse of the corresponding right-hand size value of the goal (b). Useful to balance the relevance of all goals. Equivalent to normalising the problem so b=1 for all goals.

silent

Logical. TRUE to prevent the function writing anything to the console (or the default output). Default is FALSE.

Details

The actual solution of the linear programming problem is found using lp_solve https://lpsolve.sourceforge.net/, through its R interface (the lpSolve package).

Argument 'eqs' defines the goals of the goal programming problem through easy human-readable text. When writing a constranit, all variables must be on the left-hand side, with only numeric values on the right-hand side. Equations must be valid R expressions. Examples of valid equations are the following:

On the other hand, the following are not valid expressions:

While optional, it is highly encouraged to provide names for each goal. The user can also provide weights and/or lexicographic priorities for the positive (excess) and negative (lack) deviations associated to each goal. The following example shows how to provide this information: " Labour : 20*A + 12*B + 40*C = 1200 | 0.2 0.1 | 1# 2# Profit : 11*A + 16*B + 8*C = 1000 | 0.1 0.3 | 3# 4# Batteries: 4*A + 3*B + 6*C = 200 | 0.2 0.1 | 5# 6#" The name of the goal must be followed by a colon (:) or split vertical bars (|). Then the goal. Then the weights associated to the positive deviation first (excess), and the negative deviation (lack) last, separated by an empty space. Finally, the lexicographic priorities for the positive (excess) and negative (lack) deviations can be provided as numbers, each followed by a hashtag, and separated by an space, in that order. Lower values imply a higher priority, and the same priority can be assigned to multiple deviations. Only the equation is mandatory. If the weights are omitted, all of them are assumed to be equal to one. If the lexicographic priorities are omitted, all of them are assumed to be equal to one.

Value

goalp object. It contains the following elements.


[Package goalp version 0.3.1 Index]