I am trying to find a particular number from a basic math formula using optimization method so it can tweak slider on it own. For example: if x/y + y/z + z/x = 6.125 , my input would be with three sliders for each x,y,z and I need combinations of different numbers giving 6.125
if x = 16, y = 4, z = 2 it gives 6.125 from above equation but I need all possible combinations within certain range. Is it possible to set galapogos or octopus to find particular combination for the number we need?
Surely there’s an infinite amount of combinations that yield that result, or are x, y and z always integers?
This sounds like an algebraic problem, not an optimisation problem. You’re looking for all answers to a specific question, which means either writing them down algebraically or solving the relationships as equations.
Yes the numbers should be positive integers. Ok but is there any way to find those numbers that gives similar answer?
don’t want to interrupt, but I think this is similar to a question I had (If I misunderstood, just ignore me)
What I think he is saying is this:
let’s say x+y=z
can you give all variables x,y,z as an input but z being a ‘hard’ input, so if for example z=12
when you take the x slider to 6, y will slide on its own to 6
when you take the x slider to 5, y will go (again on its own) to 7 and so on…
If they are integers then it may be tractable, especially if your limits are tight. Using a brute force approach may be do-able.
Here’s a quick file I wrote just now to visualise the solution space: xyz.gh (15.9 KB)
Aris you are right, am trying to find something like that
David May I know how the result will give me 6.125 with equations? I think you made into curves but am talking about simple algebra / quadratic equations
The curves are just there to aid intuitive insight. Whenever the curve intersects an integer coordinate you have a solution. Here’s a brute force approach with tolerance: xyz_bruteforce.gh (25.3 KB)
If you want to search much bigger ranges, or add more variables, it probably makes more sense to switch to genuine code, as that allows you to iterate over all possible solutions without having to remember the wrong ones too. Although of course a genuine algebraic solution would be preferable.
Your solution is impressive and I tried for more range to get more combinations it crashed. So do you think I should go for galapogas?
I feel that I’m being intrusive here,
but since @greatsaiyamandbz agreed, I am continuing for the last time:
this is an imaginary component that with a range of 1 component, it locks a given value and whenever one of the inputs changes, the other one changes accordingly (and I guess this could be made to work with more than two inputs with some kind of hierarchy)
I know drawing pictures is much easier than doing the code, and it might conflict with the entire architecture of GH. but I’m just saying it would be nice!
No, galapagos will only give you one solution, you’re looking for all solutions that match the problem.
There’s no functionality build into the GH SDK that would allow components to operate in reverse. Indeed for almost all components that would be impossible, really simple ones like adding two numbers being the exception. But what if the addition has an extra input, how do you distribute the ‘error’ to B and C when A changes?
"some kind of hierarchy"
from the top of my hat, top inputs (as you see them on the battery) come first.
Here I’m showing the addition but where this would REALLY rock would be with expression
I understand there are many complications
for example if you had a trig. function it would probably not only have to change the values of the sliders but their nature as well (from Natural to Real/ negative/ what have you)
I was reluctant to pose this question in the past for exactly these reasons.
(but many times I find myself doing the operations on paper when this way -if it could be done- it would just be a matter of identifying the result you want and let the machine do the work for you-)
Crashed how? Was there an error message? Crash report window?
Not entirely sure, but is seems like combinatorial generation might be appropriate here (see a GHPython implementation here), where in your case one might generate all the combinations for a set, and then check the results against the function to find best fit candidates within the generated combinations.
Rhino closed by itself. Then I increased by using disable solver and enabling it later it gave error and system hanged
lock component is a separate component you downloaded from food4rhino?
it’s just a picture I drew! I’m just saying it would be nice if it existed!
Ignore my posts, I’m being theoretical. Not going to help you with your problem.
Listen to the other guys.
Aha! would be cool to generate combinations. It will be very useful for me when I was trying to find constants (value used in Engineering) that I use in formulations.
Expression component gave this error “1. Expression generated an error for (x, y, z): Left hand value of operator / is Null” when I increased range