문제

I have a system of nonlinear dynamics which I which to solve to optimality. I know how to do this in MATLAB, but I wish to implement this in JAVA. I'm for some reason lost in how to do it in Java.

What I have is following:
z(t) which returns states in a dynamic system.

z(t) = [state1(t),...,state10(t)]

The rate of change of this dynamic system is given by:

z'(t) = f(z(t),u(t),d(t)) = [dstate1(t)/dt,...,dstate10(t)/dt]

where u(t) and d(t) is some external variables that I know the value of. In addition I have a function, lets denote that g(t) which is defined from a state variable:

g(t) = state4(t)/c1

where c1 is some constant.

Now I wish to solve the following unconstrained nonlinear system numerically:

g(t) - c2 = 0

f(z(t),u(t),0)= 0

where c2 is some constant. Above system can be seen as a simple f'(x) = 0 problem consisting of 11 equations and 1 unkowns and if I where supposed to solve this in MATLAB I would do following:

[output] = fsolve(@myDerivatives, someInitialGuess);

I am aware of the fact that JAVA doesn't come with any build-in solvers. So as I see it there are two options in solving the above mentioned problem:
Option 1: Do it my-self: I could use numerical methods as e.g. Gauss newton or similar to solve this system of nonlinear equations. However, I will start by using a java toolbox first, and then move to a numerical method afterwards.

Option 2: Solvers (e.g. commons optim) This solution is what I am would like to look into. I have been looking into this toolbox, however, I have failed to find an exact example of how to actually use the MultiVariateFunction evaluater and the numerical optimizer. Does any of you have any experience in doing so?

Please let me know if you have any ideas or suggestions for solving this problem. Thanks!

도움이 되었습니까?

해결책

Please compare what your original problem looks like:


A global optimization problem

minimize f(y)

is solved by looking for solutions of the derivatives system

0=grad f(y) or 0=df/dy (partial derivatives)

(the gradient is the column vector containing all partial derivatives), that is, you are computing the "flat" or horizontal points of f(y).


For optimization under constraints

minimize f(y,u) such that g(y,u)=0

one builds the Lagrangian functional

L(y,p,u) = f(y,u)+p*g(y,u)  (scalar product)

and then compute the flat points of that system, that is

g(y,u)=0, dL/dy(y,p,u)=0, dL/du(y,p,u)=0

After that, as also in the global optimization case, you have to determine what the type of the flat point is, maximum, minimun or saddle point.


Optimal control problems have the structure (one of several equivalent variants)

minimize integral(0,T) f(t,y(t),u(t)) dt

such that y'(t)=g(t,y(t),u(t)), y(0)=y0 and h(T,y(T))=0

To solve it, one considers the Hamiltonian

H(t,y,p,u)=f(t,y,u)-p*g(t,y,u)

and obtained the transformed problem

y' = -dH/dp = g, (partial derivatives, gradient)
p' =  dH/dy, 
   with boundary conditions 
       y(0)=y0, p(T)= something with dh/dy(T,y(T)) 
u(t) realizes the minimum in v -> H(t,y(t),p(t),v) 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top