How to find the best combinations of calculation of function with 36 input constants, each constant is possible to calculate in 3 ways
Show older comments
Hi community,
I have a function with 36 constants (it possible to image the function as an surface). Each of the 36 constant is possible to calculate in 3 ways (named/substituted for example as 0, 1, 2). It is totally 3 ^ 36 of possible combinations. I am looking for the best combination to find the minimum sum error from reference values set.
My idea to solve it was with brute force at first: for each combination 1 to 3 ^ 36 to calculate input control vector in ternary system (0...000, 0...001, 0...002, 0...010, etc.) and then to evaluate function output (based on control vector) for each reference values set. If the solution was better than previous one, I stored the "better combination" and go to the next combination. But the solution takes unreal time.
It is there any better solution how to solve it? I read something about optimalization toolbox, but I am not familiar with it. I read also about parfor function, but my solution described above is evaluating every step if is better than previous one. So, I don’t know, if it is even possible to calculate it in parallel way.
Thank you in Advance
9 Comments
Let assume you can evalute 1000 combinations by second it will take you
nopspersec = 1000;
nbsecperh = 3600;
nbhperday = 24;
nbdayperyear = 365;
timeinyear = 3^36/nopspersec/nbsecperh/nbhperday/nbdayperyear
5 billions years to evaluate all the combinations.
Still want to do brute force?
Lubos Brezina
on 16 Nov 2023
Bruno Luong
on 16 Nov 2023
"Would you have any advice how to solve it in more efficiently way please?"
You only describe your problem very surperficially (36 variables each take 3 value). The dependency of the objectiive to those parameters can be then anything. There is no way we can give you any useful advide from that little information.
As an aside, an easier way to compute how long an operation will take (at N combinations per second) is to use duration functionality.
format longg
numCombinations = 3^36
combinationsPerSecond = 1000;
yearsRequired = years(seconds(numCombinations/combinationsPerSecond))
Lubos Brezina
on 17 Nov 2023
Moved: Bruno Luong
on 17 Nov 2023
Bruno Luong
on 17 Nov 2023
If I was you I use ga rather than gamultiobj, by defining the least-squares fit of data to model.
Lubos Brezina
on 18 Nov 2023
Bruno Luong
on 18 Nov 2023
Edited: Bruno Luong
on 18 Nov 2023
A least squares problem is minimizing the objective function defined as
norm(abs(model(param) - data)^2
or
sum(abs(model(param) - data).^2)
sum is over output variables (your surface data).
Such objective function usually eases the minimizer for convergence.
Might be you problem is simply too hard to solve
Lubos Brezina
on 19 Nov 2023
Answers (1)
Brute force is NEVER going to be a good idea. Instead, if you have the global optimization toolbox...
help ga
4 Comments
Lubos Brezina
on 16 Nov 2023
Edited: Lubos Brezina
on 16 Nov 2023
John D'Errico
on 16 Nov 2023
Which parts of GA? You just need to read the help for GA. Look at the examples. I'm not sure what else to say.
You have 36 variables, all of which will take on 3 different levels, so you can think of them as having the levels 1,2, or 3. Then use those as an index to generate the actual levels of those variables.
Torsten
on 16 Nov 2023
I have no knowledge about "ga". Maybe you can help here: Is "ga" really better suited for this problem than simply testing a fixed number of random triples ?
Lubos Brezina
on 16 Nov 2023
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!