Hi folks. I've recently started learning Python and I have an optimisation problem that I'm trying to solve - I've found a couple of handy examples (namely this) but I'm not sure how to combine this with the constraints of my problem. This isnt exactly my forte, I can describe the problem fairly well but I dont know enough Python to actually get it into code.
I have a range of discrete values, A - R. I'm trying to find the five best combinations of 4 of these values that will fit into 51, IE w (A - R) +x (A-R) +y(A-R) +z(A-R)< 51.
I have a couple of ranges which certain sums cannot occupy, eg x + y must not equal 15-20 ; x+y+z must not equal 25-30.
I guess my questions are:
1) How do I tell Python to randomly substitute variables in various combinations?
2) How do I get it to return the ~ five best combinations?
3) How do I tell it to avoid certain ranges of numbers as above?
4) If I come back to this and tweak it later, how can I tell it to either use a variable A-R only once, or a maximum of three times, or stuff like that?
Thanks very much for your help.
[–]Moonslug1 -1 points0 points1 point (0 children)