Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Tugas 05

Jhonny Rionaldo Gulo

19/6/2021

##Package untuk optimasi linear


library(lpSolve)

decision <- c(20, 60)

##Contraint matrix
mat <- matrix(c(30, 20, 5, 10), nrow = 2, byrow = TRUE)

##Defining Contraints
const_jaker <- 2700
const_james <- 850

##RHS for contraints


rhs <- c(const_jaker, const_james)

##Direction for contraints


dir <- c("<=", "<=")

##Finding Optimum Solution


opts <- lp(direction = "max", decision, mat, dir, rhs)

summary(opts)

## Length Class Mode


## direction 1 -none- numeric
## x.count 1 -none- numeric
## objective 2 -none- numeric
## const.count 1 -none- numeric
## constraints 8 -none- numeric
## int.count 1 -none- numeric
## int.vec 1 -none- numeric
## bin.count 1 -none- numeric
## binary.vec 1 -none- numeric
## num.bin.solns 1 -none- numeric
## objval 1 -none- numeric
## solution 2 -none- numeric
## presolve 1 -none- numeric
## compute.sens 1 -none- numeric
## sens.coef.from 1 -none- numeric
## sens.coef.to 1 -none- numeric
## duals 1 -none- numeric
## duals.from 1 -none- numeric
## duals.to 1 -none- numeric
## scale 1 -none- numeric
## use.dense 1 -none- numeric
## dense.col 1 -none- numeric
## dense.val 1 -none- numeric
## dense.const.nrow 1 -none- numeric
## dense.ctr 1 -none- numeric
## use.rw 1 -none- numeric
## tmp 1 -none- character
## status 1 -none- numeric

##Objective value a, b, c, d
opts$solution

## [1] 0 85

Dari hasil ini bisa dilihat bahwa


##Value of objective function at optimal point
opts$objval

## [1] 5100

You might also like