


Constant
Usage:
>> DoubleConstant(value);
Parameters:
name A numeric [NUMERIC or acado.MexInput]
Example:
>> acado.DoubleConstant(1.5);
>> acado.DoubleConstant(acado.MexInput());
Licence:
This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/)
ACADO Toolkit -- A Toolkit for Automatic Disturbance 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: 2009-2010


0001 %Constant 0002 % 0003 % Usage: 0004 % >> DoubleConstant(value); 0005 % 0006 % Parameters: 0007 % name A numeric [NUMERIC or acado.MexInput] 0008 % 0009 % Example: 0010 % >> acado.DoubleConstant(1.5); 0011 % >> acado.DoubleConstant(acado.MexInput()); 0012 % 0013 % Licence: 0014 % This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) 0015 % 0016 % ACADO Toolkit -- A Toolkit for Automatic Disturbance and Dynamic Optimization. 0017 % Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. 0018 % Developed within the Optimization in Engineering Center (OPTEC) under 0019 % supervision of Moritz Diehl. All rights reserved. 0020 % 0021 % ACADO Toolkit is free software; you can redistribute it and/or 0022 % modify it under the terms of the GNU Lesser General Public 0023 % License as published by the Free Software Foundation; either 0024 % version 3 of the License, or (at your option) any later version. 0025 % 0026 % ACADO Toolkit is distributed in the hope that it will be useful, 0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0029 % Lesser General Public License for more details. 0030 % 0031 % You should have received a copy of the GNU Lesser General Public 0032 % License along with ACADO Toolkit; if not, write to the Free Software 0033 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0034 % 0035 % Author: David Ariens 0036 % Date: 2009-2010 0037 % 0038 classdef DoubleConstant < acado.Operator 0039 properties(SetAccess='private') 0040 val; 0041 end 0042 0043 methods 0044 function obj = DoubleConstant(val) 0045 global ACADO_; 0046 0047 if (isa(val, 'numeric')) 0048 ACADO_.count_double = ACADO_.count_double+1; 0049 0050 obj.val = val; 0051 obj.name = strcat('acadoconstant', num2str(ACADO_.count_double)); 0052 0053 ACADO_.helper.addInstruction(obj); 0054 0055 elseif (isa(val, 'acado.MexInput')) 0056 0057 if (val.type ~= 1) 0058 error('MexInput should be in this case a numeric value, not a vector or matrix.'); 0059 end 0060 0061 obj.name = val.name; 0062 0063 else 0064 error('DoubleConstant expects a numeric value or a acado.MexInput'); 0065 end 0066 end 0067 0068 0069 getInstructions(obj, cppobj, get) 0070 0071 0072 function s = toString(obj) 0073 % toString is used in epxressions (eg 2 + x -> DoubleConstant + 0074 % DifferentialState) 0075 s = obj.name; 0076 0077 end 0078 end 0079 end 0080