-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProject11292021.Rmd
120 lines (87 loc) · 3.95 KB
/
Project11292021.Rmd
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
title: "Project11292021"
author: "Riad Alharithi"
date: "12/1/2021"
output: pdf_document
---
$i$ is set of Employees {E1, E2, ..} varie from 1 to $n=$ total number of employees
$j$ is set of projects { P1, P2, ..} varies one to $p=$ total number of porjects
$k$ is set of classifications {class 1, class 2, ..} varies from 1 to $c=$ number of classifications at the company
[**Variable:**]{.ul}
$X_i,_j,_k$ [Continuous]{.ul}: Hours that an employee $i$ work in functional class $k$ in project $j$
$Y_i,_j,_k$ = ${0, 1}$ [Binary]{.ul} variable, If employee $i$ is assigned to classification $k$ for project $j$ then $y_i,_j,_k$is 1 otherwise it is 0.
### Data
$S_{i,k}$ =1 [Binary]{.ul}, if employee is qualified to do task $k$
$P_i,_k$: [Continuous]{.ul}, Profit = Hourly rate for employee $i$ classification $k$ in project $j$ \* 10% \*
$R_{i,k}$: [Continuous]{.ul}, billing rate for $i$ when performing task classification $k$
$T_{j,k}$ [Continuous]{.ul}, Total hours per project for task classification $k$
[**Objective Function:**]{.ul}
$$
\begin{split}
\begin{aligned}
\text{Maximize } & \sum_{i} \sum_{j} \sum_{k} X_{i,j,k} \cdot P_{i,k} \\
\end{aligned}
\end{split}
$$
[**Constraints**]{.ul}
- Utilization: Total hours assigned to a staff who classified as engineer/ designer/ surveyor should not exceed 1664 hours per year.
$\sum_{j=1}^{j=p} \sum_{k=1}^{k=c} X_{i,j,k} \leq1664 \,\text { hours } \forall i$
- Big M: Linking the constraints, in this scenario each staff can not be assigned more than the total hours per task
$X_{i,j,k}\leq T[j,k] * Y_{i,j,k} \,\forall i,j,k$
- Skills set: Every staff $i$ assigned on any project $j$ should have the appropriate skill.
for example, Junior Engineer can not do Senior Engineer task but the opposite is correct.
$Y_{i,j,k}\leq S_{i,k}\ \forall\ i, j, k$
- Total Hours constraints: the total hours for each staff $i$ on every project should be less than or equal than the negotiated hours in the project budget.
$\sum_{i=1}^{i=n} X_{i,j,k} \geq T_{j,k} \forall j,k$
Including the libraries:
```{r}
library(ompr, quietly = TRUE)
library(magrittr, quietly = TRUE)
library(pander, quietly = TRUE)
library(ROI, quietly = TRUE)
library(ROI.plugin.glpk, quietly = TRUE)
library(ompr.roi, quietly = TRUE)
library(pander, quietly = TRUE)
library(TRA)
library(Benchmarking, quietly=TRUE)
library(ROI.plugin.glpk)
library(ROI.plugin.lpsolve)
library(ROI.plugin.neos)
library(ROI.plugin.symphony)
library(readr)
#library(ROI.plugin.cplex)
```
```{r Data, echo=FALSE}
XIJ<-readr::read_csv("//Users/riad/!Riad/PhD/Classes/ETM 640/Project/XIJ.csv")
TS<- readr::read_csv("/Users/riad/!Riad/PhD/Classes/ETM 640/Project/StaffSKills.csv")
S<-t(TS)
TP<-readr::read_csv("//Users/riad/!Riad/PhD/Classes/ETM 640/Project/PIK.csv")
P<-t(TP)
Td <- t(XIJ)
Assignement_Table<-matrix(0, nrow=10, ncol=9)
Bilingrate<-readr::read_csv("/Users/riad/!Riad/PhD/Classes/ETM 640/Project/BillingRates.csv")
Classifications<-readr::read_csv("/Users/riad/!Riad/PhD/Classes/ETM 640/Project/Classifications.csv")
UtilizationRate<-readr::read_csv("/Users/riad/!Riad/PhD/Classes/ETM 640/Project/UtilizationRate.csv")
n<-10
## Number of Staff
p<-6
##Number of projects
c<-7
## Number of classifications
```
```{r model Variables, objective, Constraints}
model <- MIPModel()
model<- add_variable(model, X[i,j,k], i=1:n, j=1:p, k=1:c, lb=0, type= "continuous")
model<- add_variable(model, Y[i,j,k], i=1:n, j=1:p, k=1:c, type = "binary")
model<- set_objective(model, sum_expr((X[i,j,k]*P[i,k]), i=1:n, j=1:p, k=1:c), "max")
model<- add_constraint (model, Y[i,j,k]<=S[i,k], i=1:n, j=1:p, k=1:c)
model<- add_constraint(model,sum_expr(X[i,j,k], j=1:p, k=1:c) <=1664, i=1:n)
model<- add_constraint(model,sum_expr(X[i,j,k],i=1:n) == Td[j,k], j=1:p, k=1:c)
model<- add_constraint (model, X[i,j,k]<=Td[j,k]*Y[i,j,k], i=1:n, j=1:p, k=1:c)
result <- solve_model(model, with_ROI(solver = "glpk"))
result
t <- get_solution(result,X[i,j,k])
Assignement_Table<-t
```
```{}
```