octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Roberto Porcù
Subject:
Date: Tue, 10 Dec 2013 11:25:07 +0000

Hi all,
I'm working on the implementation of RATTLE algorithm for the SOCIS project.
I implemented a function called  odeRATTLE which signature is the following:

[T,Y] = odeRATTLE(@Hamilton_equations, @constraint, time_vector, initial_conditions, options)

where constraint should be a function_handle useful to impose  g(q)=0  where q are the generalized coordinates.
In the algorithm is also necessary the gradient of  g  with respect to q   and I  made the possibility for the user to  pass the explicit _expression_ of
this gradient to the solver  or not (in this latest case the program will calculate an approximation of the gradient).

My problem is with the case in which the user passes the explicit _expression_ for the gradient of g.
I want this _expression_ included into the  @constraint   function_handle, for example returned as second output argument.
But if I pass that as second argument then I can just evaluate the gradient at a given point, but what I need is
to use that _expression_ as a function_handle because  it's needed in the system to solve with fsolve.

I found out the following solution for this problem but I want to know if you think it's a good solution or if it is
computationally expensive and there is something better. Thanks in advance.

In my solution the function_handle  @constraint   must return a  cell  containing as first element the constraint function
and as second element the gradient of this constraint function, so that what the program does is to define  G = @(q) (g(q){2})  :


flag = 0;
  try
    G = g(x(1:dim)){2};
  catch
    flag = 1;
    warning('rattle: gradient of bounding function will be approximated');
  end

  if( flag==1 )
    G = @(q) differential(gg,q);  %% differential is the approximating function for the gradient
  else
    G = @(q) (g(q){2});
  end



Thanks
Roberto Porcù



reply via email to

[Prev in Thread] Current Thread [Next in Thread]