How to find a constrained distribution within an array that results in an optimum.
2 views (last 30 days)
Show older comments
Jordy van der Pol
on 26 Apr 2017
Commented: Alan Weiss
on 1 May 2017
Hi,
This is my first time posting here so please bear with me. I have been struggling with an optimization problem for a while now and was hoping somebody here might have a solution or can steer me in the right direction.
I have a function: y = a * b * c * x. a, b, c are arrays of 20 elements which are constants and I am trying to optimize y. The problem now lies with x.
x is also an array with 20 elements, however each value can take a value ranging from 0 to a certain maximum value. The problem now is, is that the array x summed up has to be a certain value. I am thus trying to optimize y for a certain distribution of values over the array x, while the summed value stays the same.
x is also an array with 20 elements, however each value can take a value ranging from 0 to a certain maximum value. The problem now is, is that the array x summed up has to be a certain value. I am thus trying to optimize y for a certain distribution of values over the array x, while the summed value stays the same.
I hope my explanation is clear enough and if you have any questions please let me know.
Any help would be greatly appreciated.
0 Comments
Accepted Answer
Alan Weiss
on 26 Apr 2017
I suppose that when you say that you want to "optimize" y, you want to minimize or maximize the sum of the elements in that multiplication. And I suppose that the multiplication is element-wise, meaning the objective function has to do with
sum_I(a(I)*b(I)*c(I)*x(I))
where the a, b, and c are given vectors of numbers. Your constraints are that each x(I) must lie in a certain range, and the sum of the x(I) must equal a given number.
If I am correct about all these suppositions, then you can use the linprog solver in Optimization Toolbox to solve your problem. If I am wrong about something, then please clarify where I misunderstood.
Alan Weiss
MATLAB mathematical toolbox documentation
5 Comments
Alan Weiss
on 1 May 2017
You could also try lowering the ConstraintTolerance option to, say, 1e-9.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!