0

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!

chthonicdaemon
  • 19,180
  • 2
  • 52
  • 66
Rémy
  • 9
  • 2
  • Please include the code that you have written. – bad_coder Feb 04 '20 at 14:35
  • Sure, I've added the link – Rémy Feb 04 '20 at 15:45
  • Please include the code as text in the question. That way it shows up in search, and other members seeking to help you, can copy and edit the code to their needs. (This specific question could have been better suited for the [codereview](https://codereview.stackexchange.com/) site.) Take into consideration: https://stackoverflow.com/help/minimal-reproducible-example – bad_coder Feb 04 '20 at 15:48
  • That's not a question for codereview, I'm just asking how to have an integer step on SciPy's minimizer function... – Rémy Feb 04 '20 at 16:02
  • Ok, then I'm probably wrong @Rémy (I meant it as a possibility). I'm just a reviewer who came across your question by chance, and pointed out the usual best practices to posting. I hope you get your answer soon, I'm not a scipy expert... Welcome to stackoverflow. – bad_coder Feb 04 '20 at 16:12

0 Answers0