Thanks for looking into this. Indeed, with your new settings, I don't see
anymore cases where the result doesn't sastify the constraints... however in
some cases I now have NLOPT_FAILURE exceptions instead.
If you want to look into it, I attached a set of data which generates such
failure (to use with the code I previously sent, modified like you said).
Regards
Christophe
PS: Anectotically, I tried setting the inequality tolerance to 0 as you
suggested: in many cases, it returns with a ROUNDOFF error. I guess that's a
separate issue though.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steven G. Johnson
Sent: 26 November 2011 20:02
To: nlopt-discuss
Subject: Re: [NLopt-discuss] MMA method moving out of feasible region
Thanks for the sample code; I can reproduce your problem and have a fix.
On each step, the MMA algorithm calls NLopt recursively to optimize a
convex local model of the objective and constraints in a trust
region. (Technically, it solves the dual problem rather than the
primal one.) It looks like you are running into a limitation stemming
from NLopt not solving this subsidiary problem accurately enough.
You can override NLopt's defaults for solving this subsidiary problem
by the set_local_optimizer method. In particular, add the following
lines to your computeNLOpt function before calling optimize:
nlopt::opt dual_opt(nlopt::LD_LBFGS,n);
dual_opt.set_ftol_rel(1e-14);
optim.set_local_optimizer(dual_opt);
This fixes the problem for me.
In the next release, I should probably lower the default tolerance for
the dual problem. You can alternatively do this yourself by applying
the following patch to api/optimize.c. Change:
nlopt_set_ftol_rel(dual_opt, LO(ftol_rel, 1e-12));
to
nlopt_set_ftol_rel(dual_opt, LO(ftol_rel, 1e-14));
Steven
PS. You can feel free to set a tolerance of zero for inequality
constraints. A nonzero tolerance is only really important for
equality constraints.
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
double c_initialGuess [10] =
{0.00000000000000000,0.00000000000000000,0.00000000000000000,1.3615545952967615e-006,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.99999863844540460};
double c_Returns [10] =
{0.54887793802426765,0.61751199719677663,1.0056936808713788,0.70264875262099435,1.2681189531337389,0.89162779789141933,1.0363214031151116,1.6863708727333653,0.50252436574045456,0.0017164652890202562};
double c_PreviousWeights [10] =
{7.9296546517915959e-009,0.13343904407795934,0.12038396936068220,1.1654524446208514e-009,0.12484022011342719,9.7610943308214237e-012,0.14223258241985048,0.12039637381938344,1.0372156797358004e-008,0.35870779073167242};
double c_TradingCosts [10] =
{1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010,1.0000000000000000e-010};
double c_LinearConstraints [10] =
{0.21336067241732407,0.18991458187032439,0.25324816914359255,0.21707560341349869,0.28680730267652688,0.25836521886274427,0.24018158127433631,0.31288332677440683,0.27816354356724587,0.00000000000000000};
double c_MinWeights [10] =
{0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.00000000000000000,0.38838969784577504};
double c_MaxWeights [10] =
{0.12398909399675517,0.14678647251701399,0.11246960776814076,0.12127113305295693,0.11455596356309901,0.12896165231609116,0.13664204866492904,0.10928846021757514,0.10319928472598131,1.0000000000000000};
double c_maxVol = 0.13;
double c_linearMax = 0.15290257553855624;
double c_CovarMat [55] =
{0.0691618403490189,0.0516782386196448,0.0541984895631381,0.0601061223402073,0.0482946484408198,0.0949855650754341,-0.0294759004059871,-0.0234571559977929,-0.00665529856852499,0.0708283839204414,0.0100257943800583,0.00469350156231258,0.0330050809103946,0.030412639994569,0.120536969544694,0.00056944641705815,-0.00588237486515642,0.00894292510350873,0.00546193626485539,0.0832905895848035,0.0999359486174174,0.0415145989978538,0.0270684513228745,0.056823982244479,0.0202531871111661,0.0528516338551098,0.0238437387663981,0.0847547694033051,0.0338248258351794,0.0107473516927421,0.0573612497615158,0.0189138752376079,0.100557358436117,0.0593601931896393,0.0705604388992696,0.139604360984135,0.029116597666789,0.0202648297493694,0.0555392681577344,0.0216108392254869,0.0630144653167551,0.0416155800962016,0.0603490973686683,0.0706321159944792,0.118654516622591,1.82494026207246E-06,2.37789386078496E-06,2.80850974570031E-07,-9.19059731117964E-08,1.78362350404384E-06,3.82202442711482E-06,1.08294206802517E-06,4.28094077279909E-07,1.64972936507229E-06,4.53099493172083E-09};_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss