import marimo __generated_with = "0.6.22" app = marimo.App(width="medium") @app.cell def __(): import cvxpy as cp import numpy as np import marimo as mo return cp, mo, np @app.cell def __(np): # cost vector (dollars per kg of food) c = np.array([6, 5, 2, 15]) # Nutrient content matrix # Rows corresponding to grams of protein, carbohydrates, and fat per kg of food. # The food types in the columns are lentils, broccoli, rice, and almonds. A = np.array([ [250, 28, 20, 210], [600, 60, 780, 200], [10, 3, 10, 500] ]) # Minimum required nutrients vector (grams per day). b = np.array([50, 300, 70]) return A, b, c @app.cell def __(A, b, c, cp): x = cp.Variable(4, nonneg=True) cost = c @ x constraints = [A @ x >= b] problem = cp.Problem(cp.Minimize(cost), constraints) problem.solve() print(x.value) print(cost.value) return constraints, cost, problem, x if __name__ == "__main__": app.run()