I have a programming problem that I want to optimize. To optimize it I have to calculate the minimum value that's possible for one variable given a set of equations (where some but not all variables are known at runtime). Is there any good automatized system that does that job for me and that gives me a formula given my constraints?

New Answer

Ask Related Question

New Comment

# 2 Answers

What kind of constraints do you have?

There are many constraint solvers for different kinds of equations. I enjoyed using pySMT, which provides a Python wrapper for several different libraries: pysmt/pysmt: pySMT: A library for SMT formulae manipulation and solving (github.com).

Maybe look at GAMS

What equations are you using? Is there something special about them which makes you think your particular problem is tractable? A Bayesian optimization hyperparameter search like Facebook's Adaptive Experimentation Platform (Ax) might help if you're searching a continuous, differentiable space. Technically-speaking, an efficient general solution is probably impossible to construct within physical reality since it involves reversing trapdoor functions.

b²=m²+z², c²=n²+z², b²=o²+q², w²=o²+r², c²=s²+v², w²=v²+t² and y =b+c, z=m+n, x=q+r, l=s+t. I know that all values are positive. The space is continuous and differentiable. I know y,z,x and l at excecution time and want to know the minimal w that's possible for the system.

I feel like I should have enough information to have be able to calculate a decent value value for the minimal w.

I've used

`Optim.jl`

for similar problems with good results, here's an example: https://julianlsolvers.github.io/Optim.jl/stable/#user/minimization/The example looks to me like it gives the library one equation that has to be minimized. I on the other hand have a bunch of equations.

Of course what you asked for is information about computer systems for solving this kind of thing, but the particular system of equations you have here isn't so hard to make sense of (but, caution, I make a lot of mistakes, so if you want to make any use of what follows I strongly advise you to check it).

So, let's begin with the quantities z,m,n,b,c. z is known; m,n are constrained by having to add up to z, and z,m,n interact with the other variables only via b,c. Oh, and we also know y=b+c, so we've got two constraints on b,c which means we should expect there to be only finitely many possibilities for (b,c); let's see what they are.

This sort of thing is a bit painful by hand, but e.g.

Mathematicacan do it instantly. (Though it doesn't give what seems to me the simplest form, so I've made some hand-simplifications which of course might have introduced errors.) It turns out that b,c arey2±z2√y2−5z2y2−z2

which isn't too painful. OK, now we split up x as q+r and l as s+t, and then from b,q we calculate o and from c,s we calculate v, and then we have two expressions for w which need to be equal. So that gives us b2−q2+r2=c2−s2+t2 which looks a bit unpleasant, but notice that we can write r2−q2=(r−q)x where r−q can take any value in [−x,+x] and similarly for s,t,l.

We have b2−c2=±yz√y2−5z2y2−z2 and this has to equal q2−r2+t2−s2 which by the remarks in the previous paragraph is δx+ϵl where |δ|≤x and|ϵ|≤l and can therefore take any value between 0 and x2+l2. So, first of all, the whole thing has solutions iff yz√y2−5z2y2−z2≤x2+l2.

And now we get w2 by offsetting b2 by something between ±x2, and also by offsetting c2 by something between ±l2, and so the smallest we can make w2 is max(0,b2−x2,c2−l2). (But remember that we can take b,c whichever way around we prefer; so we should put the + sign in b if x>l and in c if x<l.)