Advertisement
makispaiktis

Course 4 - Constraints

Aug 28th, 2023
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.35 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5. % 1. Load the dataset
  6. load Nutrition.mat
  7. food
  8.  
  9. % 2. Create the optimization problem
  10. prob = optimproblem("Description","An Optimal Breakfast");
  11. servings = optimvar("servings", 16, "LowerBound", 0)
  12. price = food.Price
  13. C = servings .* price
  14. prob.Objective = sum(C);
  15. show(prob)
  16. [sol, optval] = solve(prob)
  17. sol.servings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement