forum.alglib.net http://forum.alglib.net/ 

Alglib minnlc returns solution out of constraints http://forum.alglib.net/viewtopic.php?f=2&t=4321 
Page 1 of 1 
Author:  oln [ Wed May 06, 2020 1:23 pm ] 
Post subject:  Alglib minnlc returns solution out of constraints 
I am trying to implement a simple minimisation under a quadratic inequality constraint and a linear equality constraint as well as lower and upper bounds. My problem is as follow: min: x1*(0.00498) + x2*0.05656 u.c. : . x1^2 * 0.00001048 + 2*x1*x2*0.001431 + x2^2*0.6737996 <= 0.0084050 . x1 + x2 = 1.0 . 0 < x1 < 0.9 . 0 < x2 < 0.9 Once implemented in F# using Alglib it seems that the constraints are not respected. Neither the sum x1+x2 is equal to 1.0 nor the variance is below 0.0084. Though lower and upper bound are respected, my objective function with x2 is improved (lower) than with x0. I believe I have an issue with my formulation of the constraints, but I can't see which one. let nsfunc2_jac(x:float[]) (fi:float[])(jac:float[,])= fi.[0] < (x.[0]*0.00498+x.[1]*0.05656) fi.[2] < x.[0]+x.[1]+x.[2]1.0 fi.[1] < x.[0]*x.[0]*0.00001048 + 2.0*x.[0]+x.[1]*0.001431 + x.[1]*x.[1]*0.67379960.0084050 jac.[0,0] < 0.00498 jac.[0,1] < 0.05656 jac.[2,0] < 1.0 jac.[2,1] < 1.0 jac.[1,0] < 2*x.[0]*0.00001048 + 2*x[1]*0.001431 jac.[1,1] < 2*x.[0]*0.001431 + 2+x[1]*0.6737996 let mutable state2 = new alglib.minnlcstate() let mutable rep2 = new alglib.minnlcreport() let mutable nrep = new alglib.ndimesional_rep(func2) let x0 = [0.8999, 0.1001] alglib.minnlccreate(2,x0, &state2) alglib.minnlcsetalgoaul(state2, 1000.0, 15.0) alglib.minnlsetcond(state2, 0.000001,10.0) alglib.minnlcsetscale(state2, [1.0,1.0]) alglib.minnlcsetprecexactlowrank(state2, 5.0) alglib.minnlcsetnlc(state2, 1,1) alglib.minnlcsetbc(state2, [0.0,0.0], [0.9,0.9]) alglib.minnlcoptimize(state2, jac, nrep, None) let x2, rep = alglib.minnlcresults(state2) let var = x2.[0]*x2.[0]*0.00001048 + 2.0*x2.[0]+x2.[1]*0.001431 + x2.[1]*x2.[1]*0.6737996 printfn "Variance: %s" var.ToString() I get Var = 0.53 well above the 0.0084050 target. In fact, after the first iteration both my equality and my inequality constraints are broken and the algorithm never comes back within the range. More worisome, I receive an answer TerminationType = 1 > OK 
Page 1 of 1  All times are UTC 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ 