{"id":546,"date":"2019-09-19T16:17:01","date_gmt":"2019-09-19T19:17:01","guid":{"rendered":"https:\/\/www.blogs.unicamp.br\/zero\/?p=546"},"modified":"2022-05-23T17:21:48","modified_gmt":"2022-05-23T20:21:48","slug":"pizza-problem","status":"publish","type":"post","link":"https:\/\/www.blogs.unicamp.br\/zero\/546\/","title":{"rendered":"Pizza Problem"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"546\" class=\"elementor elementor-546\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a45d801 elementor-section-boxed elementor-section-height-default elementor-section-height-default jltma-glass-effect-no\" data-id=\"a45d801\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c49224f jltma-glass-effect-no\" data-id=\"c49224f\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4e6840a jltma-glass-effect-no elementor-widget elementor-widget-heading\" data-id=\"4e6840a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\"><a href=\"https:\/\/www.blogs.unicamp.br\/zero\/2019\/09\/19\/problema-de-pizza\/\">(Traduzir)<\/a><\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1d1fd1e jltma-glass-effect-no elementor-widget elementor-widget-text-editor\" data-id=\"1d1fd1e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p align=\"justify\">Ordering a pizza would be a trivial task if it weren&#8217;t for the option of choosing two flavors. In this text we will explain how this freedom given to the customer turns the \u201csimple\u201d action of ordering a pizza into a serious optimization problem.<\/p>\n<p align=\"justify\">First, let&#8217;s define this flavor option as follows: for each pizza we can choose up to two flavors {x; y} so that the total value of the pizza will be Max {price (x); price (y)}. To simplify communication, we will work with imaginary \u201czero-coin\u201d money or just Z $. Thus, the challenge arises for the client to find flavors {x; y} such that it minimizes the function |price(x) &#8211; price(y)|\/2 (since the most expensive half of the pizza was properly paid for its correct value). For example, take the following list of pizzas:<\/p>\n<table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">\n<colgroup>\n<col width=\"256*\"> <\/colgroup>\n<tbody>\n<tr>\n<td width=\"100%\" valign=\"top\">\n<p align=\"justify\"><i>1) pepperoni, mozzarella, onion, fried garlic \/ 20Z $<\/i><\/p>\n<p align=\"justify\"><i>2) pepperoni, mozzarella, onion, fried garlic, cheddar, bacon \/ 25Z $<\/i><\/p>\n<p align=\"justify\"><i>3) tuna, mozzarella, onion, fried garlic, cheddar \/ 25Z $<\/i><\/p>\n<p align=\"justify\"><i>4) chicken, mozzarella, onion, fried garlic, cheddar \/ 24Z $<\/i><\/p>\n<p align=\"justify\"><i>5) chicken, mozzarella, onion, fried garlic, cheddar, bacon \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>6) tuna, mozzarella, onion, fried garlic \/ 22Z $<\/i><\/p>\n<p align=\"justify\"><i>7) broccoli, mozzarella, onion, fried garlic, cheddar \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>8) pepperoni, mozzarella, onion, fried garlic, cheddar \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>9) tuna, mozzarella, onion, fried garlic, cheddar, bacon \/ 27Z $<\/i><\/p>\n<p align=\"justify\"><i>10) broccoli, mozzarella, onion, fried garlic \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>11) broccoli, mozzarella, onion, fried garlic, cheddar, bacon \/ 28Z $<\/i><\/p>\n<p align=\"justify\"><i>12) chicken, mozzarella, onion, fried garlic \/ 21Z $<\/i><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"justify\">We can simplify this menu by organizing it based on common factors, as for example all pizzas come with mozzarella, onion and fried garlic, we can omit this information in the analysis. We will distribute them in two subgroups, as the main ingredient and price. To facilitate our analysis, let&#8217;s consider that adding ingredients always makes the pizza better. Thus, a pepperoni+cheddar+bacon pizza will be better than a pepperoni+cheddar pizza, which will be better than a pepperoni pizza.<\/p>\n<table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">\n<colgroup>\n<col width=\"128*\">\n<col width=\"128*\"> <\/colgroup>\n<tbody>\n<tr valign=\"top\">\n<td width=\"50%\">\n<p align=\"justify\"><i><b>Distribution by flavor:<\/b><\/i><\/p>\n<p align=\"justify\"><i>1) pepperoni \/ 20Z $<\/i><\/p>\n<p align=\"justify\"><i>8) pepperoni, cheddar \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>2) pepperoni, cheddar, bacon \/ $ 25Z<\/i><\/p>\n<p align=\"justify\"><i>12) chicken \/ $ 21Z<\/i><\/p>\n<p align=\"justify\"><i>4) chicken, cheddar \/ 24Z $<\/i><\/p>\n<p align=\"justify\"><i>5) chicken, cheddar, bacon \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>6) Tuna \/ $ 22Z<\/i><\/p>\n<p align=\"justify\"><i>3) tuna, cheddar \/ 25Z $<\/i><\/p>\n<p align=\"justify\"><i>9) tuna, cheddar, bacon \/ 27Z $<\/i><\/p>\n<p align=\"justify\"><i>10) broccoli \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>7) broccoli, cheddar \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>11) broccoli, cheddar, bacon \/ 28Z $<\/i><\/p>\n<\/td>\n<td width=\"50%\">\n<p align=\"justify\"><i><b>Price distribution:<\/b><\/i><\/p>\n<p align=\"justify\"><i>1) pepperoni \/ 20Z $<\/i><\/p>\n<p align=\"justify\"><i>12) chicken \/ $ 21Z<\/i><\/p>\n<p align=\"justify\"><i>6) Tuna \/ $ 22Z<\/i><\/p>\n<p align=\"justify\"><i>10) broccoli \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>8) pepperoni, cheddar \/ 23Z $<\/i><\/p>\n<p align=\"justify\"><i>4) chicken, cheddar \/ 24Z $<\/i><\/p>\n<p align=\"justify\"><i>2) pepperoni, cheddar, bacon \/ $ 25Z<\/i><\/p>\n<p align=\"justify\"><i>3) tuna, cheddar \/ 25Z $<\/i><\/p>\n<p align=\"justify\"><i>5) chicken, cheddar, bacon \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>7) broccoli, cheddar \/ 26Z $<\/i><\/p>\n<p align=\"justify\"><i>9) tuna, cheddar, bacon \/ 27Z $<\/i><\/p>\n<p align=\"justify\"><i>11) broccoli, cheddar, bacon \/ 28Z $<\/i><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"justify\">So, based on the quality criterion, if we will order for example half the pizza of flavor5 (chicken, cheddar, bacon) and we want the other half with pepperoni based ingredient, we have the following situations:<\/p>\n<p align=\"center\"><i>Max {price (flavor5); price (flavor1)} =<\/i><\/p>\n<p align=\"center\"><i>= Max {26Z $; 20Z $} = 26Z $.<\/i><\/p>\n<p align=\"center\"><i>Max {price (flavor5); price (flavor8)} =<\/i><\/p>\n<p align=\"center\"><i>= Max {26Z $; 23Z $} = 26Z $.<\/i><\/p>\n<p align=\"center\"><i>Max {price (flavor5); price (flavor2)} =<\/i><\/p>\n<p align=\"center\"><i>= Max {26Z $; 25Z $} = 26Z $.<\/i><\/p>\n<p align=\"justify\">Analyzing the function |price(x) &#8211; price(y)| to be minimized for each case, we have:<\/p>\n<p align=\"center\"><i>|price(flavor5) &#8211; price(flavor1)|\/2 = 3Z$.<\/i><\/p>\n<p align=\"center\"><i>|price(flavor5) &#8211; price(flavor8)|\/2 = 1,5Z$.<\/i><\/p>\n<p align=\"center\"><i>|price(flavor5) &#8211; price(flavor2)|\/2 = 0,5Z$.<\/i><\/p>\n<p align=\"justify\">Therefore, flavor2 minimizes the cost in this case. On the other hand, if only the flavor5 was defined, that is, the other half of the pizza had no flavor restriction, we would have a better solution when choosing the flavor7.<\/p>\n<p align=\"center\"><i>Max {price (flavor5); price (flavor7)} =<\/i><\/p>\n<p align=\"center\"><i>= Max {26Z$; 26Z$} = 26Z$.<\/i><\/p>\n<p align=\"center\"><i>|price (flavor5) &#8211; price (flavor7)| = 0Z$.<\/i><\/p>\n<p align=\"justify\">Now if two pizzas are ordered, we have the possibility to choose up to 4 flavors. Its cost will be given by the expression:<\/p>\n<p align=\"center\"><i>[Max {price (x); price (y)} + Max {price (w); price (z)}].<\/i><\/p>\n<p align=\"justify\">Thus, the challenge arises for the client to find flavors {x; y; w; z} and rearrange them in a way that minimizes the function [|price(x) &#8211; price(y)| + |price(w) &#8211; price(z)|]\/2. In this case, we have in addition to the problem of choosing, the problem of rearranging. Because 4 flavors (called 1, 2, 3 and 4) could be arranged in 3 ways:<\/p>\n<p align=\"center\"><i>{1; 2} &amp; {3; 4} \/\/ {1; 3} &amp; {2; 4} \/\/ {1; 4} &amp; {2; 3}<\/i><\/p>\n<p align=\"justify\">Considering the same menu used in the case of just one pizza, suppose that customers want a main flavor of each type (pepperoni, chicken, tuna and broccoli), respectively, and do not insist on extras (but if possible, they want). Then we have flavor1 (pepperoni\/20Z$), flavor12 (chicken\/21Z$), flavor6 (tuna\/22Z$) and flavor10 (broccoli\/23Z$).<\/p>\n<p align=\"center\"><i>{flavor1; flavor12} &amp; {flavor6; flavor10} = total to pay 44Z$<\/i><\/p>\n<p align=\"center\"><i>{flavor1; flavor6} &amp; {flavor12; flavor10} = total to pay 45Z$<\/i><\/p>\n<p align=\"center\"><i>{flavor1; flavor10} &amp; {flavor6; flavor12} = total to pay 45Z$<\/i><\/p>\n<p align=\"justify\">Now calculating the differences for each option, we have:<\/p>\n<p align=\"center\"><i>[|price(flavor1) \u2013 price(flavor12)|<\/i><\/p>\n<p align=\"center\"><i>+ |price(flavor6) \u2013 price(flavor10)|]\/2 = 1Z$.<\/i><\/p>\n<p align=\"center\"><i>[|price(flavor1) \u2013 price(flavor6)|<\/i><\/p>\n<p align=\"center\"><i>+ |price(flavor12) \u2013 price(flavor10)|]\/2 = 2Z$.<\/i><\/p>\n<p align=\"center\"><i>[|price(flavor1) \u2013 price(flavor10)|<\/i><\/p>\n<p align=\"center\"><i>+ |price(flavor6) \u2013 price (flavor12)|]\/2 = 2Z$.<\/i><\/p>\n<p align=\"justify\">The first option may seem the most interesting, but the third option allows us to improve the pepperoni pizza, asking for the flavor8 (pepperoni, cheddar) instead.<\/p>\n<p align=\"center\"><i>{flavor8; flavor10} &amp; {flavor6; flavor12} = total to pay 45Z$<\/i><\/p>\n<p align=\"center\"><i>[|price(flavor8) \u2013price(flavor10)|<\/i><\/p>\n<p align=\"center\"><i>+ |price(flavor6) \u2013 price(flavor12)|]\/2 = 0,5Z$.<\/i><\/p>\n<p align=\"justify\">So, if we think about which option we will spend less, in the first option we spend 44Z $, however the waste (the extra amount paid for the pizza) is 1Z $. Whereas in the fourth option we spend 45Z $, but the waste in this case is 0,5Z $.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d181403 elementor-section-boxed elementor-section-height-default elementor-section-height-default jltma-glass-effect-no\" data-id=\"d181403\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7130560 jltma-glass-effect-no\" data-id=\"7130560\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a84e3a8 jltma-glass-effect-no elementor-widget elementor-widget-heading\" data-id=\"a84e3a8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\"><a href=\"https:\/\/www.blogs.unicamp.br\/zero\/\">Back to main page<\/a><\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d2118eb elementor-section-boxed elementor-section-height-default elementor-section-height-default jltma-glass-effect-no\" data-id=\"d2118eb\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-905801c jltma-glass-effect-no\" data-id=\"905801c\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0a7fb8a jltma-glass-effect-no elementor-widget elementor-widget-heading\" data-id=\"0a7fb8a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\"><a href=\"https:\/\/www.blogs.unicamp.br\/zero\/who-writes-the-posts\/\">Who writes the posts?<\/a><\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Can optimization help you buy more tasty pizzas while spending less, did you feel hungry for knowledge? Come and taste &#8230;<\/p>\n","protected":false},"author":434,"featured_media":548,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[1209],"tags":[],"class_list":["post-546","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-v-2-ed-2"],"_links":{"self":[{"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/posts\/546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/users\/434"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/comments?post=546"}],"version-history":[{"count":8,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/posts\/546\/revisions"}],"predecessor-version":[{"id":1683,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/posts\/546\/revisions\/1683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/media\/548"}],"wp:attachment":[{"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/media?parent=546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/categories?post=546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blogs.unicamp.br\/zero\/wp-json\/wp\/v2\/tags?post=546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}