Maximization linear system with three variables

1k Views Asked by At

Maximize C= 528r + 492s + 348wsubject to:

1) r + s + w ≥ 12
2) r ≤  4 --> r + 0 + 0 ≤  4
3) w ≥ 3s --> 0 – 3s + 1w ≥0

I can't find any code examples online where I can maximize using three variables with inequalities. The closest I found was something that looks like this from another question: Solving linear equations w. three variables using numpy

import numpy as np
a = np.array([[2, -4, 4], [34, 3, -1], [1, 1, 1]])
b = np.array([8, 30, 108])
x = np.linalg.solve(a, b)
1

There are 1 best solutions below

0
On

This kind of problem is called a linear program.

Therefore you want to look into scipy.optimize.linprog. At the bottom of that page you'll also find an example of how to solve a problem such as yours.