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 |
m |
Character vector with the relationship between the left and
right-hand side of the goals. It can be any of
|
b |
Numeric vector with the values on the right hand side of the
goals. Ignored if argument |
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
|
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
|
varType |
Named character vector. Defines the type of each variable.
It can be defined as |
normW |
Logical. TRUE to scale the weights by the inverse of the
corresponding right-hand size value of the goal ( |
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:
-
"3*x + 2*y = 16"
-
"4*x - y = 3"
On the other hand, the following are not valid expressions:
-
"3*x = 16 - 2*y"
-
"4x + 1y = 5"
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.
-
A
: The coefficient matrix of the decision variables. It does not include the coefficients of the deviations. -
m
: The relationship between the left- and right-hand side of the goals. -
b
: The right-hand side of the goals. -
w
: The weights of the deviation variables. -
p
: The lexicographic priorities of deviations variables. -
A_
: The coefficient matrix of the decision and deviation variables. -
w_
: The weights of the decision and deviation variables. -
eqs
: Text version of the goal programming problem. -
varType
: Vector describing the type of the decision variables (binary, integer, or continuous). -
x
: Optimal value of the decision variables. -
d
: Optimal value of the deviation variables. -
obj
: The value of the objective function (sum of weighted deviations). If using lexicographic priorities, the value for the objective function using all deviations (i.e. ignoring the priority) in each stage. -
X
: The value of the decision variables for the optimal solution in each stage of the lexicographic problem. If there are no lexicographic priorities, then a single row matrix. -
lp
: lp object describing the solution of the underlying linear programming problem. See lp.object. When using lexicographic priorities, the solution to the last stage. -
solutionFound
: Logical taking value TRUE if a solution was found, FALSE otherwise.