# 11/18 RM02 ## Ideas about My Algorithm Benson Chiu @ SleeptimeError --- ### Question #### Why Programmers can't distinguish between Christmas and Halloween? --- Because `OCT 31 == DEC 25` --- ### Insights - the Capacity of the logistic center is limited - the center will supply it's goods to the retailer where $Profit - rtCost$ reach the maximum value --- - the Profit have to be maximized - the stores will choose the logistic center $s.t. Profit - lgCost$ reach its maximum value, where $Profit - lgCost > 0$ - For cases $s.t.$ $Profit - lgCost = 0$, we should ignore this option (佔用社會資源) --- ### Split into two cases - Single Sourcing - Multiple Sourcing --- ### Question #### Why did the programmer quit his job? --- Cuz he didn't get arrays. :poop: --- ### Core Value : Greedy Algorithm - A greedy algorithm is a simple, intuitive algorithm that is used in **optimization problems**. - The algorithm **makes the optimal choice ==at each step==** as it attempts to find the overall optimal way to solve the entire problem. Source: https://brilliant.org/wiki/greedy-algorithm/ --- ![](https://i.imgur.com/44ennA6.png) --- ### Algorithm Prototype (Single Sourcing) - Sort retailer by fixed cost - Open the first retailer with the lowest fixed cost --- - Select the **available** logistic center s.t. $Profit - lgCost > 0$ and $Profit - lgCost$ reach its maximum value, if the logistic center had already selected, just decided by $Profit$ because the lgCost will only be minus once --- - If $\forall$ Available Logistic Centers s.t. $Profit - lgCost < 0$, this store will exit the market - Upgrade the total profit and the current inventory of the logistic center --- Repeat the same process again and again until the last retailer has gone through the process --- ![](https://i.imgur.com/EKxf4SU.png) --- ### Algorithm Prototype (Multiple Sourcing) - Sort logistic center by fixed cost - Open the first logistic center with the lowest fixed cost - Sent the goods to the retailer s.t. $Profit - rtCost > 0$, and $Profit - rtCost$ reach its maximum --- - If there were remaining goods, send the goods to the retailer with the second largest $Profit - rtCost$, doing the same process until remaining goods = 0 --- - Doing the same process until all retailer's demand were satisfied or all logistic center ( that will definitely make a profit) are opened
{"metaMigratedAt":"2023-06-16T14:44:25.130Z","metaMigratedFrom":"Content","title":"11/18 RM02","breaks":true,"contributors":"[{\"id\":\"53c29cb0-7c66-4095-b443-2a1de2064508\",\"add\":2699,\"del\":274}]"}
    211 views