views:

700

answers:

8

I have five values, A, B, C, D and E.

Given the constraint A + B + C + D + E = 1, and five functions F(A), F(B), F(C), F(D), F(E), I need to solve for A through E such that F(A) = F(B) = F(C) = F(D) = F(E).

What's the best algorithm/approach to use for this? I don't care if I have to write it myself, I would just like to know where to look.

EDIT: These are nonlinear functions. Beyond that, they can't be characterized. Some of them may eventually be interpolated from a table of data.

+3  A: 
Martijn
a continuous function, that doesn't have a derivative or is too complex should be done by brents method. It's a combination of parabola interpolation and golden bisection, it can be adapted for minimum and maximum optimizations, and the code is pretty straight forward, check out NUMERICAL RECIPES in C for further uses and optimization methods.
nlucaroni
Thanks nlucaroni for suggestion another method (that I didn't know of).
Martijn
A: 

ALGENCAN (part of TANGO) is really nice. There are Python bindings, too.

http://www.ime.usp.br/~egbirgin/tango/codes.php - " general nonlinear programming that does not use matrix manipulations at all and, so, is able to solve extremely large problems with moderate computer time. The general algorithm is of Augmented Lagrangian type ... "

http://pypi.python.org/pypi/TANGO%20Project%20-%20ALGENCAN/1.0

wrang-wrang
A: 

One solution of the equations

A + B + C + D + E = 1
F(A) = F(B) = F(C) = F(D) = F(E)

is to take A, B, C, D and E all equal to 1/5. Not sure though whether that is what you want ...

Added after John's comment (thanks!)

Assuming the second equation should read F1(A) = F2(B) = F3(C) = F4(D) = F5(E), I'd use the Newton-Raphson method (see Martijn's answer). You can eliminate one variable by setting E = 1 - A - B - C - D. At every step of the iteration you need to solve a 4x4 system. The biggest problem is probably where to start the iteration. One possibility is to start at a random point, do some iterations, and if you're not getting anywhere, pick another random point and start again.

Keep in mind that if you really don't know anything about the function then there need not be a solution.

Jitse Niesen
That solves what the question asked, but not what it meant. It sounds like the problem should have said F_1(A) + F_2(B) + ...
John D. Cook
A: 

I would try Particle Swarm Optimization first. It is very easy to implement and tweak. See the Wiki page for it.

Fantius
+1  A: 

As others have already posted, we do need some more information on the functions. However, given that, we can still try to solve the following relaxation with a standard non-linear programming toolbox.

min k
st.
A + B + C + D + E = 1
F1(A) - k = 0
F2(B) - k = 0
F3(C) -k = 0
F4(D) - k = 0
F5(E) -k = 0

Now we can solve this in any manner we wish, such as penalty method

min k + mu*sum(Fi(x_i) - k)^2 st
A+B+C+D+E = 1

or a straightforward SQP or interior-point method.

More details and I can help advise as to a good method.

m

SplittingField
A: 

Google OPTIF9 or ALLUNC. We use these for general optimization.

Mike Dunlavey
A: 

You could use standard search technic as the others mentioned. There are a few optimization you could make use of it while doing the search.

First of all, you only need to solve A,B,C,D because 1-E = A+B+C+D.

Second, you have F(A) = F(B) = F(C) = F(D), then you can search for A. Once you get F(A), you could solve B, C, D if that is possible. If it is not possible to solve the functions, you need to continue search each variable, but now you have a limited range to search for because A+B+C+D <= 1.

If your search is discrete and finite, the above optimizations should work reasonable well.

leiz
A: 

The functions are all monotonically increasing with their argument. Beyond that, they can't be characterized. The approach that worked turned out to be:

1) Start with A = B = C = D = E = 1/5
2) Compute F1(A) through F5(E), and recalculate A through E such that each function equals that sum divided by 5 (the average).
3) Rescale the new A through E so that they all sum to 1, and recompute F1 through F5.
4) Repeat until satisfied.

It converges surprisingly fast - just a few iterations. Of course, each iteration requires 5 root finds for step 2.

avalys