Question: I am trying to solve this problem using linprog from scipy.optimize. A salad is any combination of the following ingredients: (1) tomato, (2) lettuce, (3) spinach, (4) carrot, and (5) oil. Each salad must contain: (A) at least 15 grams of protein, (B) at least 2 and at most 6 grams of fat, (C) at least 4 grams of carbohydrates, (D) at most 100 milligrams of sodium. Furthermore, (E) you do not want your salad to be more than 50% greens by mass. The nutritional contents of these ingredients (per 100 grams) are  Solve a linear program which makes the salad with the fewest calories under the nutritional constraints. I think I might be doing something wrong with my constraints, any advice is welcome. linprog(c=21, 16, 371, 346, 884], A_ub=[[0.85, 0.162, 12.78, 8.39, 0], [0.33, 0.02, 1.58, 1.39, 0], [4.64, 2.37, 74.69, 80.70, 0], [9, 8, 7, 508, 0], [0, 0, 0, 0, 0]] , b_ub=[15, 2, 4,100,50], bounds=[(0, None), (0, None), (0, None), (0, None), (0, None)]) 

Answer: As you have few variables and constraints, we can write your constraints like this: # (A) protein, at least (*) 15 <= 0.85*x[tomato] + 1.62*x[lettuce] + 12.78*x[spinach] + 8.39*x[carrot] + 0.0*x[oil] # (B1) fat, at least (*) 2 <= 0.33*x[tomato] + 0.2*x[lettuce] + 1.58*x[spinach] + 1.39*x[carrot] + 100.0*x[oil] # (B2) fat, at most 0.33*x[tomato] + 0.2*x[lettuce] + 1.58*x[spinach] + 1.39*x[carrot] + 100.0*x[oil] <= 6 # (C) carbo, at least (*) 4 <= 4.64*x[tomato] + 2.37*x[lettuce] + 74.69*x[spinach] + 80.7*x[carrot] + 0.0*x[oil] # (D) sodium, at most 9.0*x[tomato] + 8.0*x[lettuce] + 7.0*x[spinach] + 508.2*x[carrot] + 0.0*x[oil] <= 100  (*) However, as @AirSquid wrote, you can't pass lower bounds for constraints with linprog, you have to change the sense of the constraints to set upper bounds. # (A) protein, at least -> change inequation sens -0.85*x[tomato] + -1.62*x[lettuce] + -12.78*x[spinach] + -8.39*x[carrot] + -0.0*x[oil] <= -15 # (B1) fat, at least -> change inequation sense -0.33*x[tomato] + -0.2*x[lettuce] + -1.58*x[spinach] + -1.39*x[carrot] + -100.0*x[oil] <= -2 # (B2) fat, at most 0.33*x[tomato] + 0.2*x[lettuce] + 1.58*x[spinach] + 1.39*x[carrot] + 100.0*x[oil] <= 6 # (C) carbo, at least -> change inequation sense -4.64*x[tomato] + -2.37*x[lettuce] + -74.69*x[spinach] + -80.7*x[carrot] + -0.0*x[oil] <= -4 # (D) sodium, at most 9.0*x[tomato] + 8.0*x[lettuce] + 7.0*x[spinach] + 508.2*x[carrot] + 0.0*x[oil] <= 100   (E) you do not want your salad to be more than 50% greens by mass.  It means: # (E) green mass x[lettuce] + x[spinach] <= 0.5*(x[tomato] + x[lettuce] + x[spinach] + x[carrot] + x[oil])  You have to simplify this expression to extract coefficients: # (E) green mass -0.5*x[tomato] + 0.5*x[lettuce] + 0.5*x[spinach] + -0.5*x[carrot] + -0.5*x[oil] <= 0  Now you are ready to create c, A_ub and b_ub parameters: c = [21, 16, 371, 346, 884] A_ub = [[-0.85, -1.62, -12.78, -8.39, -0.0], [-0.33, -0.2, -1.58, -1.39, -100.0], [0.33, 0.2, 1.58, 1.39, 100.0], [-4.64, -2.37, -74.69, -80.7, -0.0], [9.0, 8.0, 7.0, 508.2, 0.0], [-0.5, 0.5, 0.5, -0.5, -0.5]] b_ub = [-15, -2, 6, -4, 100, 0] bounds = [(0, None), (0, None), (0, None), (0, None), (0, None)]) linprog(c=c, A_ub=A_ub, b_ub=b_ub, bounds=bounds)  Output:  message: Optimization terminated successfully. (HiGHS Status 7: Optimal) success: True status: 0 fun: 232.5146989957854 x: [ 5.885e+00 5.843e+00 4.163e-02 0.000e+00 0.000e+00] nit: 3 lower: residual: [ 5.885e+00 5.843e+00 4.163e-02 0.000e+00 0.000e+00] marginals: [ 0.000e+00 0.000e+00 0.000e+00 1.292e+03 8.681e+02] upper: residual: [ inf inf inf inf inf] marginals: [ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00] eqlin: residual: [] marginals: [] ineqlin: residual: [ 0.000e+00 1.176e+00 2.824e+00 4.026e+01 0.000e+00 0.000e+00] marginals: [-3.159e+01 -0.000e+00 -0.000e+00 -0.000e+00 -2.414e+00 -3.174e+01] mip_node_count: 0 mip_dual_bound: 0.0 mip_gap: 0.0