代写代考 Workforce_Planning_matrix_form

Workforce_Planning_matrix_form

Workforce Planning (Matrix Form)

Copyright By PowCoder代写 加微信 powcoder

Expression form:
\begin{array}{rll}
\displaystyle \min_{x\in \mathbb{R}^7} & x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 \\
\,{\rm s.t.} & \begin{array}[t]{rcl}
x_1 + x_4 + x_5 + x_6 + x_7 & \geq & 14 \\
x_1 + x_2 + x_5 + x_6 + x_7 & \geq & 13 \\
x_1 + x_2 + x_3 + x_6 + x_7 & \geq & 15 \\
x_1 + x_2 + x_3 + x_4 + x_7 & \geq & 16 \\
x_1 + x_2 + x_3 + x_4 + x_5 & \geq & 19 \\
x_2 + x_3 + x_4 + x_5 + x_6 & \geq & 18 \\
x_3 + x_4 + x_5 + x_6 + x_7 & \geq & 11 \\
x_i & \geq & 0 ~~~~ \forall ~i
\end{array}
\end{array}

import numpy as np
from scipy.optimize import linprog

Matrix form:
\begin{array}{rll}
\displaystyle \min_{x\in \mathbb{R}^7} & c^T x \\
\,{\rm s.t.} & \begin{array}[t]{rcl}
A\_ub \cdot x & \leq & b\_ub \\
A\_eq \cdot x & = & b\_eq
\end{array}
\end{array}

A_ub = np.array([
[-1, 0, 0, -1, -1, -1, -1],
[-1, -1, 0, 0, -1, -1, -1],
[-1, -1, -1, 0, 0, -1, -1],
[-1, -1, -1, -1, 0, 0, -1],
[-1, -1, -1, -1, -1, 0, 0],
[ 0, -1, -1, -1, -1, -1, 0],
[ 0, 0, -1, -1, -1, -1, -1]])

b_ub = np.array([-14, -13, -15, -16, -19, -18, -11])

c = np.array([1, 1, 1, 1, 1, 1, 1])

res = linprog(c, A_eq=None, b_eq=None, A_ub=A_ub, b_ub=b_ub,
bounds=(0, None), method=’simplex’)

print (“Optimal value: %.2f” % res.fun)
print (‘x:’, res.x)

Optimal value: 22.00
x: [4. 7. 1. 4. 3. 3. 0.]

sum(res.x)

np.dot(-A_ub,res.x)

array([14., 17., 15., 16., 19., 18., 11.])

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com