BIA_T12_Optimization_exercise.Rmd 744 Bytes
Newer Older
Weigert, Andreas's avatar
Weigert, Andreas committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
title:  'Tutorial 14: Optimization'
output: html_notebook
editor_options: 
  chunk_output_type: inline
---

This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M), Information Systems and Energy Efficient Systems, University of Bamberg.


```{r}
library(lpSolve)
library(ggplot2)
```


```{r lpSolve default example}
#
# Set up problem: maximize
#   x1 + 9 x2 +   x3 subject to
#   x1 + 2 x2 + 3 x3  <= 9
# 3 x1 + 2 x2 + 2 x3  <= 15
#
objective.in <- c(1, 9, 1)
const.mat <- matrix(c(1, 2, 3, 3, 2, 2), nrow=2, byrow=TRUE)
f.dir <- c("<=", "<=")
const.rhs <- c(9, 15)
direction <- "max"
lp(direction, objective.in, const.mat, f.dir, const.rhs)
lp(direction, objective.in, const.mat, f.dir, const.rhs)$solution
```