# Fuzzy linear optimization with FuzzyLP in R

Using the FuzzyLP package in R I have demonstrated simple linear optimization of a well defined linear problem using the crispLP function in a previous post. In that example basic simplex algorithm was applied to solve the problem.

In this post a linear optimization problem with fuzzy constraints has to be solved. The problem is a maximization problem and is stated below:

When solving this problem with the FuzzyLP package one should define the problem in vector-matrix syntax. The following template should be applied:

c is the coefficient vector of the objective function. x is the vector containing the optimization variables. A is the coefficient matrix of the linear constraints and b is the vector containing the constraint values. t are the maximum contraint violation values that might occur (this is why the problem is fuzzy).

The FCLP.classicObjective function comprised by the FuzzyLP package will solve this problem while guaranteeing a certain minimum objective function value. the FCLP.classicObjective function will try to maximize beta, while at the same time guaranteeing a lower limit of the objective function value. In this example I want the solver to ensure an objective function value of at least 7.

In below coding example I model and solve the problem in R, using FCLP.classicObjective from FuzzyLP:

``````#install.packages("FuzzyLP")
library(FuzzyLP)``````
``## Warning: package 'FuzzyLP' was built under R version 3.6.2``
``````# define vectors and matrices that describe the problem at hand
c <- c(3,4)
A <- matrix(c(1,2,2,1,3,-1),nrow=3)
dir <- c("<=","<=","<=")
b <- c(1,1,1)
t <- c(4,5,3)

# solve the problem
solution <- FCLP.classicObjective(objective = c,
A = A,
dir = dir,
b = b,
t = t,
z0=7,
maximum=TRUE)``````
``## Bound reached, FCLP.fixedBeta with beta = 0.2413793 may obtain better results.``
``solution``
``````##           beta       x1        x2 objective
## [1,] 0.2413793 1.827586 0.3793103         7``````

It is recommended by the developers of this package to use another function, called FCLP.fixedBeta, after having executed FCLP.classicObjective. FCLP.fixedBeta will take a fixed value for beta and execute basic simplex for optimization.

In below example you can see how I use FCLP.fixedBeta, using the beta-value identified by the FCLP.classicObjective optimization run:

``````# solve the problem using FCLP.fixedBeta
solution <- FCLP.fixedBeta(objective = c,
A = A,
dir = dir,
b = b,
t = t,
beta = 0.24,
maximum=TRUE)``````
``## [1] "Solution is optimal."``
``solution``
``````##      beta   x1   x2 objective
## [1,] 0.24 1.83 0.38      7.01``````

A benchmark run with beta = 0 returns a optimal objective function value of 8.75. That means, for beta = 0.24 the objective function value is not maximized. This is because FCLP.classicObjective guarantees a certain lower limit and maximizes beta. It does no optimize beta to determine a maximum objective function value.

There are other approaches to conducting optimization for a problem such as the one at hand. In some of my following posts I will provide some additional examples.