Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @smmaurer and perhaps others. My team is using choicemodels to estimate some relatively large location choice models in a land use model setting and we have been having a lot of problems with convergence (using
engine == "ChoiceModels"
). In searching for suggestions on what we might be doing wrong, I've noticed a few similar issues around, notably the one at UDST/urbansim#212 from 2018.I think I might have found the culprit... Please feel free to ignore the first commit here, I'm not sure that it is material at all though it did initially seem to allow some models to converge which were failing with strange errors before. I think in particular the value of
factr
is set to be too small when callingscipy.optimize.fmin_l_bfgs_b()
I don't know what a minimum value for
factr
might be to achieve "extremely high accuracy" but I think machine precision times ten might be too high of a bar. Changing this tofactr=10e9
gets reasonably close to the tolerances being used inpylogit
(1e-06
) once divided byeps
. The implementation ofscipy.optimize.minimize()
thatpylogit
uses internally calls the same function that you are using here.Along with loosening this tolerance, I think another improvement might be to move to using that
scipy.optimimze.minimize()
interface here in choicemodels. I did see a comment somewhere in a scipy issue that directly calling the optimizers themselves should be considered deprecated. I'd be happy to tackle that change if you'd be interested in merging.What do you think?