Question: Can someone help to run this code for 1000 times and get the 1000 Qstar value using for loop?


 

> 

restart

Loading Statistics

> 

Sam := Sample(('Uniform')(10, 20), 10)

Sam := Vector[row](10, {(1) = 18.147236863931788, (2) = 19.057919370756192, (3) = 11.26986816293506, (4) = 19.133758561390195, (5) = 16.323592462254094, (6) = 10.975404049994095, (7) = 12.784982188670483, (8) = 15.468815192049838, (9) = 19.575068354342974, (10) = 19.648885351992767}, datatype = float[8])

(1)
> 

``

> 

a := min(Sam)

10.9754040499940952

(2)
> 

b := max(Sam)

19.6488853519927673

(3)
> 

M := int((Q-x)*f(x), x = 0 .. Q)

int((Q-x)*f(x), x = 0 .. Q)

(4)
> 

N := int((x-Q)*f(x), x = Q .. b)

int((x-Q)*f(x), x = Q .. 19.6488853519927673)

(5)
> 

Ecost := M*co+N*cs

(int((Q-x)*f(x), x = 0 .. Q))*co+(int((x-Q)*f(x), x = Q .. 19.6488853519927673))*cs

(6)
> 

DCost := diff(Ecost, Q)

(int(f(x), x = 0 .. Q))*co+(int(-f(x), x = Q .. 19.6488853519927673))*cs

(7)
> 

``

> 

Df := max(Sam)-min(Sam)

8.67348130

(8)
> 

NULL

> 

Val := eval(DCost, [f(x) = 1/Df, co = 20, cs = 25])

5.188228168*Q-56.63494470

(9)
> 

QStar := fsolve(Val, Q)

10.91604742

(10)
> 

NULL

> 

``

> 

NULL

> 

``


 

Download dummy_1.mw

Please Wait...