How to find a constrained distribution within an array that results in an optimum.

2 views (last 30 days)
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.

Accepted Answer

Alan Weiss
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
Jordy van der Pol
Jordy van der Pol on 27 Apr 2017
Hi,
yes that is what I mean, although the violation seems small, the constrain violation has the same value as T_p (T_p = 6.9750e-08)
The algorithm gives for each x a value of 0 at the moment. Maybe that the problem lies with the fact that the numbers the algorithm has to deal with are so small?
Yes I did realize that it minimizes, which is wat I needed.
Alan Weiss
Alan Weiss on 1 May 2017
Your problem might be poorly scaled. Try rescaling it.
You could also try lowering the ConstraintTolerance option to, say, 1e-9.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!