Optimizing 1 equation with 7 variables
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Pelajar UM
il 20 Set 2021
Modificato: Pelajar UM
il 20 Set 2021
I have the following function:
f= (a^2/x^2)-((a*(2*b))/x^2)+(2*(b^2)/y^2)+((1/x^2)-(2/y^2))*b^2+((2*(2*d)^2)/s^2)+(((y^2)^-1)-(4*x^2)^-1)*((2*z)^2);
I want to find all possible combinations of a,b,d,s,x,y,z for which f = 1 subject to the following constraints:
y<2*x
0=< a,b,d,s,x,y,z <= 1
I keep getting the "not enough input arguments" error when I try to run fmincon. Is this even a valid problem or it's too broad?
0 Commenti
Risposta accettata
John D'Errico
il 20 Set 2021
Modificato: John D'Errico
il 20 Set 2021
You do understand this is likely impossible to do?
If there are ANY solutions which satisfy the given equality, then there are almost certainly infinitely many solutions. So finding ALL such solutions will take an infinitely long time to perform.
We can probably even show there are infinitely many solutions too. For example...
syms a b d s x y z
f = 1;
eqn = (a^2/x^2)-((a*(2*b))/x^2)+(2*(b^2)/y^2)+((1/x^2)-(2/y^2))*b^2+((2*(2*d)^2)/s^2)+(((y^2)^-1)-(4*x^2)^-1)*((2*z)^2) - f;
Now, we can search for one such solution. Does one exist? For example, suppose we set a=b=s=0.5. Now you want y < 2*x, so I'll pick values for x and t that satisfy that relationship. Say y = 0.5, and x = 0.3. Now look at what we get.
pretty(subs(eqn,[a,b,x,y,s],[.5 .5 .3 .5 .5]))
This represents an ellipse in the plane, with variables d and z. It has center (0,0).
fimplicit(subs(eqn,[a,b,x,y,s],[.5 .5 .3 .5 .5]),[0 1 0 1])
axis equal
grid on
xlabel 'd'
ylabel 'z'
So as long as d is a little smaller than 0.2, then there are infinitely many solutions, all living on that ellipse. We can even solve for z as a function of d.
z_d = solve(subs(eqn,[a,b,x,y,s],[.5 .5 .3 .5 .5]),z)
We will choose only the positive root there, so the second one found. It can be written as:
vpa(z_d(2))
And clearly that root will be real (for non-negative values of d) as long as d <= sqrt(1/32).
sqrt(1/32)
So no, you cannot find ALL solutions. There is NO optimization tool that will do so. I could have chosen many sets of the variables, picking random values for them from the domain of interest. How about if we pick
a0 = rand()
b0 = rand()
d0 = rand()*.2
z0 = rand()
s0 = rand()
eqnsubs = subs(eqn,[a,b,d,z,s],[a0,b0,d0,z0,s0])
fimplicit(eqnsubs,[0 1 0 1])
hold on
fimplicit(y == 2*x,[0 1 0 1],'r')
Here we see that anything below the red curve has y <= 2*x. So there will be infinitely many solutions, all of which lie along the blue curve for that set of random parameters.
I might also point out that I had to try multiple random values for a,b,d,s and z to find a set that had any solutions at all for x and y. There were many such sets of those parameters that failed to have solutions in the unit square, [0 1]X[0 1].
1 Commento
Più risposte (1)
Alan Weiss
il 20 Set 2021
I think that you would have an easier time formulating your problem by using the problem-based approach.
However, if you really want to use the fmincon solver using its default syntax, you have to reformulate your problem so that there is just one optimization variable vector, typically called x, possibly along with other variables representing fixed parameters or data. See Writing Scalar Objective Functions and Passing Extra Parameters.
Alan Weiss
MATLAB mathematical toolbox documentation
0 Commenti
Vedere anche
Categorie
Scopri di più su Linear Programming and Mixed-Integer Linear Programming in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!