Solving n nonlinear equations with n variables using YALMIP

80 views
Skip to first unread message

Ahmed Rabee

unread,
Jan 17, 2022, 2:56:44 AM1/17/22
to YALMIP

Dear prof. Johan,

Instead of finding optimal energy flow, I am supplying some variables to find an energy flow solution. In other words, I want to solve n nonlinear equations by fixing some variables, then we obtain n equations in n variables. However, using MATLAB takes a long time, especially, this problem is solved several times using the reinforcement learning approach.  

example:

solve f(x=x0 , y) = 0 --> using 'fsolve' with trust-region-dogleg algorithm, or Newton method ('levenberg-marquardt'). I have derived the Jacobian Matrix.

My question is 

can we use YALMIP to solve nonlinear equations? Or it is meaningless. As you know nonlinear equations may have more than one solution, so it is preferred (not necessary) to find the solution with higher voltages and gas pressures. 

For example: optimize(f(x=x0, y) == 0, cost(x=x0, y)) ---> using knitro or fmincons

Another question: 

The problem can be approximated as differential-algebraic equations and DC power flow, so linear equations are driven.  Can we use a linear solver? The problem should have a unique solution for "A*x0 + B*y + C*s == 0", where s are auxiliary variables, y are the n main variables, the number of linear equations m >> n. 


Many thanks for your feedback. I am appreciating your leading efforts.

Johan Löfberg

unread,
Jan 17, 2022, 3:10:34 AM1/17/22
to YALMIP
You are just solving a feasibility problem for a nonlinear program. Whether the solver is capable of finding a solution is a different issue though. If you are fixing variables, it is not a given if adding x==x0 to the model, or doing replace(Model,x,x0) is the best approach. It depends on the model and solver, although replacing typically should lead to the best model.

Second question is just a linear systems of equations. Same thing, it is a trivial linear programming feasibility problem, and thus any solver should solve it



Ahmed Rabee

unread,
Jan 17, 2022, 3:27:33 AM1/17/22
to YALMIP
Many thanks professor for your fast replay. 
According to your words, using YALMIP with a proper solver would provide faster solution, compared with 'fsolve' algorithms. 

My last question:
Will fixing x==x0 provide a significant speedup compared with the original model (without x==x0)?  for example more than 10 times faster?
As you observed, the main task is to speedup optimal energy flow calculation using deep learning. 

Johan Löfberg

unread,
Jan 17, 2022, 3:36:09 AM1/17/22
to YALMIP
I don't see why you draw the conclusion that using YALMIP+some solver would be faster than using fsolve (which is a solver)

Saying "fixing x==x0" is not clear. Do you mean to replace x with x0 in the model (i.e. eliminate x) or do you mean adding the constraint x==x0 to the model. In either case, it might be faster, or slower or make no difference.

Ahmed Rabee

unread,
Jan 17, 2022, 3:43:47 AM1/17/22
to YALMIP

Ok, Thank you very much. 
I am eliminating x using replace(Model,x,x0). And I will check the speed and compare with fsolve. 
Thanks again.
Reply all
Reply to author
Forward
0 new messages