I get a message that reads 'Desired error not necessarily achieved due to precision loss.'
Why exactly does that happen and How do I find out what the true ideal result is?
I found better results by iterating different starting values with nested for-loops. But I don't think my nested for-loops will hit a better value than the one where it returns
sucess:True
Here is a short version of my code:
def func (coefficients):
a_coef, b_coef, c_coef, d_coef, e_coef = coefficients
#This is a sum equation that I stitched together, I'll add a screenshot of the actual equation below, in case it helps anyone
return (((a_cost+d_cost)*icpa*a_adj*a_coef*d_adj*d_coef)-(a_conv+d_conv))**2+(((a_cost+e_cost)*icpa*a_adj*a_coef*e_adj*e_coef)-(a_conv+e_conv))**2+(((b_cost+d_cost)*icpa*b_adj*b_coef*d_adj*d_coef)-(b_conv+d_conv))**2+(((b_cost+e_cost)*icpa*b_adj*b_coef*e_adj*e_coef)-(b_conv+e_conv))**2+(((c_cost+d_cost)*icpa*c_adj*c_coef*d_adj*d_coef)-(c_conv+d_conv))**2+(((c_cost+e_cost)*icpa*c_adj*c_coef*e_adj*e_coef)-(c_conv+e_conv))**2
result = optimize.minimize(func, (1.2,1.2,1,0.6,1.2))
print(result)
This is my output:
fun: 20773.023398686084
hess_inv: array([[ 2.21447705e-05, 2.33193163e-05, 1.49303033e-05,
-1.24123199e-05, -3.18490802e-05],
[ 2.33193163e-05, 2.56532976e-05, 1.60651145e-05,
-1.33677287e-05, -3.39619186e-05],
[ 1.49303033e-05, 1.60651145e-05, 1.03618906e-05,
-8.50741092e-06, -2.18606606e-05],
[-1.24123199e-05, -1.33677287e-05, -8.50741092e-06,
7.07829337e-06, 1.80616076e-05],
[-3.18490802e-05, -3.39619186e-05, -2.18606606e-05,
1.80616076e-05, 4.92572403e-05]])
jac: array([0.02050781, 0.02294922, 0.04882812, 0.16308594, 0.00244141])
message: 'Desired error not necessarily achieved due to precision loss.'
nfev: 323
nit: 16
njev: 52
status: 2
success: False
x: array([1.49116998, 1.53997584, 1.06245875, 0.88491235, 2.15146809])
It might be worth mentioning, that my mathematical understanding doesn't suffice to understand what is happening in the background. For instance when I try the Nelder-Mead method, I get a success but the the result is still larger than the result of a failed attempt with the default method.