weidade37211

110 Reputation

5 Badges

6 years, 94 days

MaplePrimes Activity


These are questions asked by weidade37211

Below is my code (I hope copy paste is ok.....)

restart;

OB := add(px[i]*(px[i]-py[i])*(1-Sw[i])*fclass[i], i = 1 .. 6); # this is my objective function

px := Vector[row](6, [0.6e-2, 0.5e-2, 0.4e-3, 0.3e-2, 0.2e-3, 0.1e-3]);

py := Vector[row](6, [0.9e-2, 0.8e-2, 0.7e-2, 0.6e-2, 0.5e-3, 0.4e-3]);

fclass := Vector[row](6, [0.1e-4, 0.9e-4, 0.9e-3, 0.9e-2, 0.9e-1, .9]);  # assign some numbers for the parameters

with(Optimization);

Maximize(OB, {add(Sw[i]*fclass[i], i = 1 .. 6) = 0.001, Sw[1] <= 1, Sw[2] <= 1, Sw[3] <= 1, Sw[4] <= 1, Sw[5] <= 1, Sw[6] <= 1}, assume = nonnegative);

  [-1.08216000000000 *10^-7 , [Sw[1] = 1., Sw[2] = 0., Sw[3] = 0., ] Sw[4] = 0.110000000000000, Sw[5] = 0., Sw[6] = 0.]

The Optimization result is -1.08216*10^-7. However, this is clearly not right, since with the below solution for Sw[i], the result is bigger and the constaint still hold...(i.e. add(Sw[i]*fclass[i], i = 1 .. 6) = 0.001)

[-1.07676000000000*10^(-7), [Sw[1] = 1., Sw[2] = 1., Sw[3] = 0., Sw[4] = .1, Sw[5] = 0., Sw[6] = 0.]]

I cannot see what's wrong...Can we simply blame the floating point is not easy for Maple to handle??

Thanks.

first question:

Define a two point distribution:
f1(x):=piecewise(x = 0, 0.3, x = 0.1, 0.7, 0)

Dist1 := Distribution(PDF = f1)

R1 := RandomVariable(Dist1)

Mean(R1)

Why Mean(R1) gives 0? should be 0.07...

If I managed to define antother discrete point distribution say R2. Can I define R:=R1+R2 and then caculate Mean(R) or even plot PDF of R?

 

1 2 3 4 5 6 Page 6 of 6