0

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!

14
  • 1
    Can you include what it means for z'(t) which is an array of 10 values to be 0 ? Java doesn't come with solving libraries, you need to implement these yourself. Commented Dec 20, 2013 at 11:10
  • 2
    Since Java doesn't come with math solving libraries, then there are 2 (maybe 3) ways to handle it: 1. Download a library that has support for mathematics - maybe commons.apache.org/proper/commons-math comes in handy; 2. Mix matlab with java: you may want to take a look at mathworks.com/products/javabuilder and stackoverflow.com/questions/1607933/…; and 3. Do it by yourself Commented Dec 20, 2013 at 11:12
  • I think you would be best off doing a Google search for (say) "java nonlinear optimization" and ploughing through the search hits. Commented Dec 20, 2013 at 11:21
  • I have refined the questions now regarding the commons optim toolbox, which I already have looked into - but failed to implement. Commented Dec 20, 2013 at 11:22
  • @PeterLawrey z'(t)=0, means that the statevector z(t) should not change in value. Commented Dec 20, 2013 at 11:25

1 Answer 1

0

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) 
Sign up to request clarification or add additional context in comments.

1 Comment

why is this accepted as an answer? It doesn't provide a solution. I am asking because I was looking to solve a non linear system myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.