Given a set of equations representing goals of a linear goal programming problem, it finds the optimal solution.
goalp(
eqs,
A = NULL,
m = NULL,
b = NULL,
w = NULL,
p = NULL,
varType = NULL,
normW = FALSE,
silent = FALSE
)
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.
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).
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.
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.
Numeric vector with the values on the right hand side of the
goals. Ignored if argument eqs
is provided.
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.
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.
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.
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.
Logical. TRUE to prevent the function writing anything to the console (or the default output). Default is FALSE.
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.