I'm using SciPy's optimization functions (in particular shgo()
) in order to optimize my problem. Right now I'm managing to get a valid solution, however I would like to improve this a little bit.
My function is solving a NLU problem. Basically, I have a tokenized sentence and for each word I have a potential interpretation. For each combination I can apply black box grammar rules which will result in a score.
The problem with this is that in terms of complexity it can be disastrous, since it's O(exp(n))
.
For this reason I'm using the shgo()
optimization algorithm (or similar things) which so far gives me good results, the only thing is that the minimizing function uses real values instead of integer, yet my parameters are integer (word 1 = interpretation 2, word 2 = interpretation 1, ..., word N = interpretation I).
In the end, for some options that are fairly obvious (1 interpretation or less for each word) it takes 170 runs because it's trying to find the exact value while it's actually exploring things in the range [0, 1[ which is actually all the same thing for me.
I would like to have integer steps but after playing with the different parameters a bit I couldn't find how to tell the minimizer to have smaller steps. Even if it's not strictly integers, just have the thing to stop when it's 0.5 away from a solution would already be a wonderful improvement.
Edit: you can have a look at the code if you want.
Thanks!