# Question:My first algorithm and my first time programming...

## Question:My first algorithm and my first time programming...

Maple
Maple Professionals: This is my first time programming. I wish to compute a marginal analysis algorithm, where I basically want to find the best bang per buck in each step. I increase the variable s[i] one after another by 1 and look at the change in the perforance realtive to the cost. Then I wish to increase that s[i] by 1 for which I could see the largest increase in performance relative to cost. In the end I wish to stop when the performance measure DFR is larger than 85%. However at the moment I especially face the difficulty to raise that s[i] by one, which reached the largest relative performance increase. At the moment I got this far and would be more than grateful for any help from your side: ``` > restart; > with(stats); > Digits := 14: BASIC DATA > N := 4 > L := 0.0027397260273973 # Lead Time > lambda := [0.2, 0.6, 0.3, 0.7] # Demand per part > c:=vector([200,1000,300,750]): # Item value per part > s:=vector([0,0,0,0]): # Inventory Starting Point PERFORMANCE MEASURE(OLD) > DFR := add(lambda[i]*(sum((L*lambda[i])^k*evalf(exp(-L*lambda[i]))/factorial(k), k = 0 .. s[i]-1)), i = 1 .. N)/add(lambda[i], i = 1 .. N) PERFORMANCE MEASURE (when s(i) is increased by 1 one after another) > for i to 4 do s[i] := s[i]+1; DFRnew[i] := add(lambda[i]*(sum((L*lambda[i])^k*evalf(exp(-L*lambda[i]))/factorial(k), k = 0 .. s[i]-1)), i = 1 .. N)/add(lambda[i], i = 1 .. N); s[i] := '0' end do; "MARGINAL INCREASES FOR ALL i (one after another)" > for i to 4 do MI[i] := c[i]/(DFRnew[i]-DFR) end do; TAKE THE PART WITH THE BEST BANG PER BUCK(MI) AND INCREASE s[i] FOR THAT PART BY 1 > m := -infinity; for i to 4 do if m (smaller than) MI[i] then m := MI[i]; print(i) end if; end do; ``` Thank You....
﻿