Table of contents

Solving and analyzing a model: the diet problem

About this task

This well-known optimization problem identifies the best mix of foodstuffs to meet dietary requirements while minimizing costs. The data inputs are the nutritional profile and price of different foods and the min and max values for nutrients in a diet. The model is expressed as the minimization of a linear program. The files used in this sample are available in the DO-samples project, which is preinstalled in Watson Studio.

Procedure

  1. In the navigation pane, select Projects> View all Projects, then click DO-samples.
  2. On the DO-samples project page, click Models in the Assets tab, and locate and open the Diet model.
    A default Scenario 1 is available with the model, and three data assets are attached to Scenario 1.
  3. In the Prepare Input Data view, you can see the data assets imported.
    These tables represent the min and max values for nutrients in the diet (diet_nutrients), the nutrients in different foods (diet_food_nutrients), and the price and quantity of specific foods (diet_food).
    Tables of input data in Prepare Input Data view
  4. Click Run Model in the sidebar to view your model.
    The Python model minimizes the cost of the food in the diet while satisfying minimum nutrient and calorie requirements.
  5. Run the model using the Run button on the top right of the Model view.

Results

Once the model is solved, the page refreshes with the Solution view displayed. The solution contains a list of foods and their quantities, along with the nutrients that they provide. KPIs are also shown in this Solution view.

In the Dashboard, the solution is displayed as a table and a chart in the Solution page. You can add notes, different types of tables and charts to show input data, solution data or KPIs by selecting and editing the Dashboard widgets. You can also create different pages in the Dashboard. For example, an Input page is also provided in this sample. See Dashboard.

You're ready to start running comparisons between different scenarios. For example, the basic solution contains a quantity of hot dog. You might want to check an alternate solution for someone who prefers a vegetarian diet.