Home > matlab > acado > packages > +acado > @DifferentialEquation > linkCFunction.m

linkCFunction

PURPOSE ^

Link a black box c function to an ACADO problem.

SYNOPSIS ^

function linkCFunction(obj, fcnfile, fcnname)

DESCRIPTION ^

Link a black box c function to an ACADO problem.

  Usage:
    >> linkCFunction(fcnfile, fcnname)

  Parameters:
    fcnfile  link to a c function. This c function should have at least
             this method called fcnname:
               void [fcnname]( double *x, double *f, void *user_data ){
                   // x -> input vector,   f -> output vector
                   // sequence in x:  t,x,u,p,w  (analogous to ode calls)
               }

  Example:
    >> f = acado.DifferentialEquation();
    >> f.linkCFunction('cfunction.cpp', 'AcadoDifferentialEquation') or
       f.linkCFunction('mysubfolder/cfunction.cpp', 'AcadoDifferentialEquation');
  
       File: cfunction.cpp:
               void AcadoDifferentialEquation( double *x, double *f, void *user_data ){
                   f[0] = x[1];
               }

  Licence:
    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)

    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
    Developed within the Optimization in Engineering Center (OPTEC) under
    supervision of Moritz Diehl. All rights reserved.

    ACADO Toolkit is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 3 of the License, or (at your option) any later version.

    ACADO Toolkit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with ACADO Toolkit; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    Author: David Ariens
    Date: 2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function linkCFunction(obj, fcnfile, fcnname)
0002 %Link a black box c function to an ACADO problem.
0003 %
0004 %  Usage:
0005 %    >> linkCFunction(fcnfile, fcnname)
0006 %
0007 %  Parameters:
0008 %    fcnfile  link to a c function. This c function should have at least
0009 %             this method called fcnname:
0010 %               void [fcnname]( double *x, double *f, void *user_data ){
0011 %                   // x -> input vector,   f -> output vector
0012 %                   // sequence in x:  t,x,u,p,w  (analogous to ode calls)
0013 %               }
0014 %
0015 %  Example:
0016 %    >> f = acado.DifferentialEquation();
0017 %    >> f.linkCFunction('cfunction.cpp', 'AcadoDifferentialEquation') or
0018 %       f.linkCFunction('mysubfolder/cfunction.cpp', 'AcadoDifferentialEquation');
0019 %
0020 %       File: cfunction.cpp:
0021 %               void AcadoDifferentialEquation( double *x, double *f, void *user_data ){
0022 %                   f[0] = x[1];
0023 %               }
0024 %
0025 %  Licence:
0026 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0027 %
0028 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0029 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0030 %    Developed within the Optimization in Engineering Center (OPTEC) under
0031 %    supervision of Moritz Diehl. All rights reserved.
0032 %
0033 %    ACADO Toolkit is free software; you can redistribute it and/or
0034 %    modify it under the terms of the GNU Lesser General Public
0035 %    License as published by the Free Software Foundation; either
0036 %    version 3 of the License, or (at your option) any later version.
0037 %
0038 %    ACADO Toolkit is distributed in the hope that it will be useful,
0039 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0040 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0041 %    Lesser General Public License for more details.
0042 %
0043 %    You should have received a copy of the GNU Lesser General Public
0044 %    License along with ACADO Toolkit; if not, write to the Free Software
0045 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0046 %
0047 %    Author: David Ariens
0048 %    Date: 2010
0049 %
0050 
0051 if (~isempty(obj.matlabODE_fcnHandle) || ~isempty(obj.matlabDAE_fcnHandle) || ~isempty(obj.cfunction_file))
0052    error('Only _one_ Matlab DAE or ODE can be linked.');
0053 end
0054 
0055     obj.cfunction_file = fcnfile;
0056     obj.cfunction_function = fcnname;
0057 
0058 end

www.acadotoolkit.org/matlab
Generated on Tue 01-Jun-2010 20:14:12 by m2html © 2005