# Question:Optimization, not really the optimised solution.

## Question:Optimization, not really the optimised solution.

Maple 2017

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.

﻿