From 8efadb6d8eb346ba8939af8993569772e8982da4 Mon Sep 17 00:00:00 2001
From: Animesh Baranawal
Date: Tue, 26 Jan 2016 00:24:57 +0530
Subject: Functions created, fminimax and fgoalattain logic fixed for off
option
---
macros/Checkdims.sci | 56 +++++++++++++++++++++
macros/Checklhs.sci | 79 ++++++++++++++++++++++++++++++
macros/Checkrhs.sci | 102 ++++++++++++++++++++++++++++++++++++++
macros/Checktype.sci | 65 ++++++++++++++++++++++++
macros/Checkvector.sci | 63 ++++++++++++++++++++++++
macros/fgoalattain.bin | Bin 79072 -> 0 bytes
macros/fgoalattain.sci | 88 +++++++++++++++++++++------------
macros/fgoalattainFunctions.bin | Bin 10432 -> 0 bytes
macros/fgoalattainFunctions.sci | 76 ----------------------------
macros/fminimax.bin | Bin 85724 -> 0 bytes
macros/fminimax.sci | 106 +++++++++++++++++++++++++++++-----------
macros/fminimaxCheckdims.bin | Bin 8332 -> 0 bytes
macros/fminimaxCheckdims.sci | 56 ---------------------
macros/fminimaxChecklhs.bin | Bin 10472 -> 0 bytes
macros/fminimaxChecklhs.sci | 79 ------------------------------
macros/fminimaxCheckrhs.bin | Bin 13076 -> 0 bytes
macros/fminimaxCheckrhs.sci | 102 --------------------------------------
macros/fminimaxChecktype.bin | Bin 9252 -> 0 bytes
macros/fminimaxChecktype.sci | 65 ------------------------
macros/fminimaxCheckvector.bin | Bin 9760 -> 0 bytes
macros/fminimaxCheckvector.sci | 63 ------------------------
21 files changed, 498 insertions(+), 502 deletions(-)
create mode 100644 macros/Checkdims.sci
create mode 100644 macros/Checklhs.sci
create mode 100644 macros/Checkrhs.sci
create mode 100644 macros/Checktype.sci
create mode 100644 macros/Checkvector.sci
delete mode 100644 macros/fgoalattain.bin
delete mode 100644 macros/fgoalattainFunctions.bin
delete mode 100644 macros/fgoalattainFunctions.sci
delete mode 100644 macros/fminimax.bin
delete mode 100644 macros/fminimaxCheckdims.bin
delete mode 100644 macros/fminimaxCheckdims.sci
delete mode 100644 macros/fminimaxChecklhs.bin
delete mode 100644 macros/fminimaxChecklhs.sci
delete mode 100644 macros/fminimaxCheckrhs.bin
delete mode 100644 macros/fminimaxCheckrhs.sci
delete mode 100644 macros/fminimaxChecktype.bin
delete mode 100644 macros/fminimaxChecktype.sci
delete mode 100644 macros/fminimaxCheckvector.bin
delete mode 100644 macros/fminimaxCheckvector.sci
diff --git a/macros/Checkdims.sci b/macros/Checkdims.sci
new file mode 100644
index 0000000..0936222
--- /dev/null
+++ b/macros/Checkdims.sci
@@ -0,0 +1,56 @@
+
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the GNU LGPL license.
+
+function errmsg = Checkdims ( funname , var , varname , ivar , matdims )
+ // Generates an error if the variable has not the required size.
+ //
+ // Calling Sequence
+ // errmsg = Checkdims ( funname , var , varname , ivar , matdims )
+ //
+ // Parameters
+ // funname : a 1 x 1 matrix of strings, the name of the calling function.
+ // var : a 1 x 1 matrix of valid Scilab data type, the variable
+ // varname : a 1 x 1 matrix of string, the name of the variable
+ // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
+ // matdims : 1 x 2 matrix of floating point integers, the number of rows, columns for the variable #ivar
+ // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
+ //
+ // Description
+ // This function is designed to be used to design functions where
+ // the input argument has a known shape.
+ // This function cannot be use when var is a function, or more
+ // generally, for any input argument for which the size function
+ // does not work.
+ // Last update : 05/08/2010.
+ //
+ // Examples
+ // // The function takes a 2 x 3 matrix of doubles.
+ // function y = myfunction ( x )
+ // Checkdims ( "myfunction" , x , "x" , 1 , [2 3] )
+ // y = x
+ // endfunction
+ // // Calling sequences which work
+ // y = myfunction ( ones(2,3) )
+ // y = myfunction ( zeros(2,3) )
+ // // Calling sequences which generate an error
+ // y = myfunction ( ones(1,3) )
+ // y = myfunction ( zeros(2,4) )
+ //
+ // Authors
+ // Michael Baudin - 2010 - DIGITEO
+ //
+
+ [lhs,rhs]=argn()
+ Checkrhs ( funname , rhs , 5 )
+ Checklhs ( funname , lhs , [0 1] )
+
+ errmsg = []
+ if ( or ( size(var) <> matdims ) ) then
+ strexp = strcat(string(matdims)," ")
+ strcomp = strcat(string(size(var))," ")
+ errmsg = msprintf(gettext("%s: Expected size [%s] for input argument %s at input #%d, but got [%s] instead."), funname, strexp, varname , ivar , strcomp );
+ error(errmsg)
+ end
+endfunction
diff --git a/macros/Checklhs.sci b/macros/Checklhs.sci
new file mode 100644
index 0000000..fd47b0c
--- /dev/null
+++ b/macros/Checklhs.sci
@@ -0,0 +1,79 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the GNU LGPL license.
+
+function errmsg = Checklhs ( funname , lhs , lhsset )
+ // Generates an error if the number of LHS is not in given set.
+ //
+ // Calling Sequence
+ // errmsg = Checklhs ( funname , lhs , lhsset )
+ //
+ // Parameters
+ // funname : a 1 x 1 matrix of strings, the name of the calling function.
+ // lhs : a 1 x 1 matrix of floating point integers, the actual number of output arguments
+ // lhsset : a 1 x n or n x 1 matrix of floating point integers, the authorized number of output arguments
+ // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
+ //
+ // Description
+ // This function is designed to be used to design functions with
+ // variable number of output arguments.
+ // Notice that it is useless to call this function if the
+ // function definition does not use the varargout statement.
+ // Notice that a function as a minimum of 1 output argument.
+ // Last update : 29/07/2010.
+ //
+ // Examples
+ // // The function takes 3 input arguments and 1/2 output arguments
+ // function varargout = myfunction ( x1 , x2 , x3 )
+ // [lhs, rhs] = argn()
+ // Checkrhs ( "myfunction" , rhs , 3 : 3 )
+ // Checklhs ( "myfunction" , lhs , 1 : 2 )
+ // y1 = x1 + x2
+ // y2 = x2 + x3
+ // varargout(1) = y1
+ // if ( lhs == 2 ) then
+ // varargout(2) = y2
+ // end
+ // endfunction
+ // // Calling sequences which work
+ // myfunction ( 1 , 2 , 3 )
+ // y1 = myfunction ( 1 , 2 , 3 )
+ // [ y1 , y2 ] = myfunction ( 1 , 2 , 3 )
+ // // Calling sequences which generate an error
+ // [ y1 , y2 , y3 ] = myfunction ( 1 , 2 , 3 )
+ //
+ // // The function takes 1 or 3 output arguments, but not 2
+ // function varargout = myfunction ( x1 , x2 , x3 )
+ // [lhs, rhs] = argn()
+ // Checkrhs ( "myfunction" , rhs , 3 : 3 )
+ // Checklhs ( "myfunction" , lhs , [1 3] )
+ // y1 = x1 + x2
+ // y2 = x2 + x3
+ // y3 = x1 + x3
+ // varargout(1) = y1
+ // if ( lhs == 3 ) then
+ // varargout(2) = y2
+ // varargout(3) = y3
+ // end
+ // endfunction
+ // // Calling sequences which work
+ // myfunction ( 1 , 2 , 3 )
+ // y1 = myfunction ( 1 , 2 , 3 )
+ // [ y1 , y2 , y3 ] = myfunction ( 1 , 2 , 3 )
+ // // Calling sequences which generate an error
+ // [y1 , y2] = myfunction ( 1 , 2 , 3 )
+ //
+ // Authors
+ // Michael Baudin - 2010 - DIGITEO
+ //
+
+ errmsg = []
+ if ( and ( lhs <> lhsset ) ) then
+ lhsstr = strcat(string(lhsset)," ")
+ errmsg = msprintf(gettext("%s: Unexpected number of output arguments : %d provided while the expected number of output arguments should be in the set [%s]."), funname , lhs , lhsstr );
+ error(errmsg)
+ end
+endfunction
+
+
+
diff --git a/macros/Checkrhs.sci b/macros/Checkrhs.sci
new file mode 100644
index 0000000..6b5cf5b
--- /dev/null
+++ b/macros/Checkrhs.sci
@@ -0,0 +1,102 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the GNU LGPL license.
+
+function errmsg = Checkrhs ( funname , rhs , rhsset )
+ // Generates an error if the number of RHS is not in given set.
+ //
+ // Calling Sequence
+ // errmsg = Checkrhs ( funname , rhs , rhsset )
+ //
+ // Parameters
+ // funname : a 1 x 1 matrix of strings, the name of the calling function.
+ // rhs : a 1 x 1 matrix of floating point integers, the actual number of input arguments
+ // rhsset : a 1 x n or n x 1 matrix of floating point integers, the authorized number of input arguments
+ // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
+ //
+ // Description
+ // This function is designed to be used to design functions with
+ // variable number of input arguments.
+ // Notice that it is useless to call this function if the
+ // function definition does not use the varargin statement.
+ // Last update : 05/08/2010.
+ // Last update : 29/07/2010.
+ //
+ // Examples
+ // // The function takes 2/3 input arguments and 1 output arguments
+ // function y = myfunction ( varargin )
+ // [lhs, rhs] = argn()
+ // Checkrhs ( "myfunction" , rhs , 2:3 )
+ // Checklhs ( "myfunction" , lhs , 1 )
+ // x1 = varargin(1)
+ // x2 = varargin(2)
+ // if ( rhs >= 3 ) then
+ // x3 = varargin(3)
+ // else
+ // x3 = 2
+ // end
+ // y = x1 + x2 + x3
+ // endfunction
+ // // Calling sequences which work
+ // y = myfunction ( 1 , 2 )
+ // y = myfunction ( 1 , 2 , 3 )
+ // // Calling sequences which generate an error
+ // y = myfunction ( 1 )
+ // y = myfunction ( 1 , 2 , 3 , 4 )
+ //
+ // // The function takes 2 or 4 input arguments, but not 3
+ // function y = myfunction ( varargin )
+ // [lhs, rhs] = argn()
+ // Checkrhs ( "myfunction" , rhs , [2 4] )
+ // Checklhs ( "myfunction" , lhs , 1 )
+ // x1 = varargin(1)
+ // x2 = varargin(2)
+ // if ( rhs >= 3 ) then
+ // x3 = varargin(3)
+ // x4 = varargin(4)
+ // else
+ // x3 = 2
+ // x4 = 3
+ // end
+ // y = x1 + x2 + x3 + x4
+ // endfunction
+ // // Calling sequences which work
+ // y = myfunction ( 1 , 2 )
+ // y = myfunction ( 1 , 2 , 3 , 4 )
+ // // Calling sequences which generate an error
+ // y = myfunction ( 1 )
+ // y = myfunction ( 1 , 2 , 3 )
+ // y = myfunction ( 1 , 2 , 3 , 4, 5 )
+ //
+ // // The function takes 2 input arguments and 0/1 output arguments.
+ // // Notice that if the checkrhs function is not called,
+ // // the variable x2 might be used from the user's context,
+ // // that is, if the caller has defined the variable x2, it
+ // // is used in the callee.
+ // // Here, we want to avoid this.
+ // function y = myfunction ( x1 , x2 )
+ // [lhs, rhs] = argn()
+ // Checkrhs ( "myfunction" , rhs , 2 )
+ // Checklhs ( "myfunction" , lhs , [0 1] )
+ // y = x1 + x2
+ // endfunction
+ // // Calling sequences which work
+ // y = myfunction ( 1 , 2 )
+ // // Calling sequences which generate an error
+ // y = myfunction ( 1 )
+ // y = myfunction ( 1 , 2 , 3 )
+ //
+ // Authors
+ // Michael Baudin - 2010 - DIGITEO
+ //
+
+ errmsg = []
+ if ( and(rhs <> rhsset) ) then
+ rhsstr = strcat(string(rhsset)," ")
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while the number of expected input arguments should be in the set [%s]."), funname , rhs , rhsstr );
+ error(errmsg)
+ end
+endfunction
+
+
+
diff --git a/macros/Checktype.sci b/macros/Checktype.sci
new file mode 100644
index 0000000..3f50fa2
--- /dev/null
+++ b/macros/Checktype.sci
@@ -0,0 +1,65 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the GNU LGPL license.
+
+function errmsg = Checktype ( funname , var , varname , ivar , expectedtype )
+ // Generates an error if the given variable is not of expected type.
+ //
+ // Calling Sequence
+ // errmsg = Checktype ( funname , var , varname , ivar , expectedtype )
+ //
+ // Parameters
+ // funname : a 1 x 1 matrix of strings, the name of the calling function.
+ // var : a 1 x 1 matrix of valid Scilab data type, the variable
+ // varname : a 1 x 1 matrix of string, the name of the variable
+ // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
+ // expectedtype : a n x 1 or 1 x n matrix of strings, the available types for the variable #ivar
+ // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
+ //
+ // Description
+ // This function is designed to be used to design functions with
+ // input arguments with variable type.
+ // We use the typeof function to compute the type of the variable:
+ // see help typeof to get the list of all available values for expectedtype.
+ // Last update : 29/07/2010.
+ //
+ // Examples
+ // // The function takes a string argument.
+ // function myfunction ( x )
+ // Checktype ( "myfunction" , x , "x" , 1 , "string" )
+ // disp("This is a string")
+ // endfunction
+ // // Calling sequences which work
+ // myfunction ( "Scilab" )
+ // // Calling sequences which generate an error
+ // myfunction ( 123456 )
+ //
+ // // The function takes a string or a matrix of doubles argument.
+ // function myfunction ( x )
+ // Checktype ( "myfunction" , x , "x" , 1 , [ "string" "constant" ] )
+ // if ( typeof(x) == "string" ) then
+ // disp("This is a matrix of strings")
+ // else
+ // disp("This is a matrix of doubles")
+ // end
+ // endfunction
+ // // Calling sequences which work
+ // myfunction ( "Scilab" )
+ // myfunction ( 123456 )
+ // // Calling sequences which generate an error
+ // myfunction ( uint8(2) )
+ //
+ // Authors
+ // Michael Baudin - 2010 - DIGITEO
+ //
+
+ errmsg = []
+ if ( and ( typeof ( var ) <> expectedtype ) ) then
+ strexp = """" + strcat(expectedtype,""" or """) + """"
+ errmsg = msprintf(gettext("%s: Expected type [%s] for input argument %s at input #%d, but got ""%s"" instead."),funname, strexp, varname , ivar , typeof(var) );
+ error(errmsg);
+ end
+endfunction
+
+
+
diff --git a/macros/Checkvector.sci b/macros/Checkvector.sci
new file mode 100644
index 0000000..76bdcc6
--- /dev/null
+++ b/macros/Checkvector.sci
@@ -0,0 +1,63 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the GNU LGPL license.
+
+function errmsg = Checkvector ( funname , var , varname , ivar , nbval )
+ // Generates an error if the variable is not a vector.
+ //
+ // Calling Sequence
+ // errmsg = Checkvector ( funname , var , varname , ivar )
+ //
+ // Parameters
+ // funname : a 1 x 1 matrix of strings, the name of the calling function.
+ // var : a 1 x 1 matrix of valid Scilab data type, the variable
+ // varname : a 1 x 1 matrix of string, the name of the variable
+ // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
+ // nbval : a 1 x 1 matrix of floating point integers, the number of entries in the vector.
+ // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
+ //
+ // Description
+ // This function is designed to be used to design functions where
+ // the input argument is a vector, that is, a matrix for which
+ // nrows == 1 or ncols == 1.
+ // This function cannot be use when var is a function, or more
+ // generally, for any input argument for which the size function
+ // does not work.
+ //
+ // Examples
+ // // The function takes a vector of 3 doubles.
+ // function y = myfunction ( x )
+ // Checkvector ( "myfunction" , x , "x" , 1 , 3 )
+ // y = x
+ // endfunction
+ // // Calling sequences which work
+ // y = myfunction ( ones(1,3) )
+ // y = myfunction ( zeros(3,1) )
+ // // Calling sequences which generate an error
+ // // The following are not vectors
+ // y = myfunction ( ones(2,3) )
+ // y = myfunction ( zeros(3,2) )
+ // // The following have the wrong number of entries
+ // y = myfunction ( ones(1,3) )
+ //
+ // Authors
+ // Michael Baudin - 2010 - DIGITEO
+ //
+
+ errmsg = []
+ nrows = size(var,"r")
+ ncols = size(var,"c")
+ if ( nrows <> 1 & ncols <> 1 ) then
+ strcomp = strcat(string(size(var))," ")
+ errmsg = msprintf(gettext("%s: Expected a vector matrix for input argument %s at input #%d, but got [%s] instead."), funname, varname , ivar , strcomp );
+ error(errmsg)
+ end
+ if ( ( nrows == 1 & ncols <> nbval ) | ( ncols == 1 & nrows <> nbval ) ) then
+ strcomp = strcat(string(size(var))," ")
+ errmsg = msprintf(gettext("%s: Expected %d entries for input argument %s at input #%d, but current dimensions are [%s] instead."), funname, nbval , varname , ivar , strcomp );
+ error(errmsg)
+ end
+endfunction
+
+
+
diff --git a/macros/fgoalattain.bin b/macros/fgoalattain.bin
deleted file mode 100644
index e4d0024..0000000
Binary files a/macros/fgoalattain.bin and /dev/null differ
diff --git a/macros/fgoalattain.sci b/macros/fgoalattain.sci
index 5f519b4..d6bec24 100644
--- a/macros/fgoalattain.sci
+++ b/macros/fgoalattain.sci
@@ -89,7 +89,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
// Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);
//
//
- // By default, the gradient options for fminimax are turned off and and fmincon does the gradient opproximation of minmaxObjfun. In case the GradObj option is off and GradConstr option is on, fminimax approximates minmaxObjfun gradient using numderivative toolbox.
+ // By default, the gradient options for fminimax are turned off and and fmincon does the gradient opproximation of gattainObjfun. In case the GradObj option is off and GradConstr option is on, fminimax approximates gattainObjfun gradient using numderivative toolbox.
//
// If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
//
@@ -103,7 +103,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
//
// [c, ceq] = confun(x)
//
- // where x is a n x 1 matrix of dominmaxUbles, c is a 1 x nni matrix of doubles and ceq is a 1 x nne matrix of doubles (nni : number of nonlinear inequality constraints, nne : number of nonlinear equality constraints).
+ // where x is a n x 1 matrix of doubles, c is a 1 x nni matrix of doubles and ceq is a 1 x nne matrix of doubles (nni : number of nonlinear inequality constraints, nne : number of nonlinear equality constraints).
// On input, the variable x contains the current point and, on output, the variable c must contain the nonlinear inequality constraints and ceq must contain the nonlinear equality constraints.
//
// By default, the gradient options for fminimax are turned off and and fmincon does the gradient opproximation of confun. In case the GradObj option is on and GradCons option is off, fminimax approximates confun gradient using numderivative toolbox.
@@ -156,7 +156,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
//
//
// Examples
- // function f1 = fun(x)
+ // function f1 = gattainObjfun(x)
// f1(1)=2*x(1)*x(1)+x(2)*x(2)-48*x(1)-40*x(2)+304
// f1(2)=-x(1)*x(1)-3*x(2)*x(2)
// f1(3)=x(1)+3*x(2)-18
@@ -167,39 +167,45 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
//
// goal=[-5,-3,-2,-1,-4];
// weight=abs(goal)
- // //xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
- // //fval = [4 3.99]
+ // gval =
+ // [- 0.0000011
+ // - 63.999998
+ // - 2.0000002
+ // - 8.
+ // 3.485D-08]
+ // z =
+ // [4. 3.99]
//
- // //Run fgoalattain
- // [xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,x0,goal,weight)
+ // Run fgoalattain
+ // [x,fval,attainfactor,exitflag,output,lambda]=fgoalattain(gattainObjfun,x0,goal,weight)
//
// Authors
// Prajwala TM, Sheetal Shalini , 2015
// Check number of input and output arguments
[gattainLhs,gattainRhs] = argn()
- fgoalattainCheckrhs("fgoalattain", gattainRhs, [4 6 8 10 11 12])
- fgoalattainChecklhs("fgoalattain", gattainLhs, 1:6)
+ Checkrhs("fgoalattain", gattainRhs, [4 6 8 10 11 12])
+ Checklhs("fgoalattain", gattainLhs, 1:6)
// initialisation of fun
gattainObjfun = varargin(1)
- fgoalattainChecktype("fgoalattain", gattainObjfun, "fun", 1, "function")
+ Checktype("fgoalattain", gattainObjfun, "fun", 1, "function")
// initialisation of x0
gattainStartpoint = varargin(2)
- fgoalattainChecktype("fgoalattain", gattainStartpoint, "x0", 2, "constant")
+ Checktype("fgoalattain", gattainStartpoint, "x0", 2, "constant")
gattainNumvar = size(gattainStartpoint,"*")
- fgoalattainCheckvector("fgoalattain", gattainStartpoint, "x0", 2, gattainNumvar)
+ Checkvector("fgoalattain", gattainStartpoint, "x0", 2, gattainNumvar)
gattainStartpoint = gattainStartpoint(:)
// initialisation of goal
goal=varargin(3)
- fgoalattainChecktype("fgoalattain",goal,"goal",3,"constant")
+ Checktype("fgoalattain",goal,"goal",3,"constant")
// initialisation of weight
weight=varargin(4)
- fgoalattainChecktype("fgoalattain",weight,"weight",4,"constant")
+ Checktype("fgoalattain",weight,"weight",4,"constant")
//initialisation of A and b
if(gattainRhs < 5) then
@@ -210,13 +216,13 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
gattainB = varargin(6)
end
- fgoalattainChecktype("fgoalattain", gattainA, "A", 5, "constant")
- fgoalattainChecktype("fgoalattain", gattainB, "b", 6, "constant")
+ Checktype("fgoalattain", gattainA, "A", 5, "constant")
+ Checktype("fgoalattain", gattainB, "b", 6, "constant")
gattainNumrowA = size(gattainA,"r")
if(gattainA <> []) then
- fgoalattainCheckdims("fgoalattain", gattainA, "A", 5, [gattainNumrowA gattainNumvar])
- fgoalattainCheckvector("fgoalattain", gattainB, "b", 6, gattainNumrowA)
+ Checkdims("fgoalattain", gattainA, "A", 5, [gattainNumrowA gattainNumvar])
+ Checkvector("fgoalattain", gattainB, "b", 6, gattainNumrowA)
gattainB = gattainB(:)
end
@@ -229,13 +235,13 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
gattainBeq = varargin(8)
end
- fgoalattainChecktype("fgoalattain", gattainAeq, "Aeq", 7, "constant")
- fgoalattainChecktype("fgoalattain", gattainBeq, "beq", 8, "constant")
+ Checktype("fgoalattain", gattainAeq, "Aeq", 7, "constant")
+ Checktype("fgoalattain", gattainBeq, "beq", 8, "constant")
gattainNumrowAeq = size(gattainAeq,"r")
if(gattainAeq <> []) then
- fgoalattainCheckdims("fgoalattain", gattainAeq, "Aeq", 7, [gattainNumrowAeq gattainNumvar])
- fgoalattainCheckvector("fgoalattain", gattainBeq, "beq", 8, gattainNumrowAeq)
+ Checkdims("fgoalattain", gattainAeq, "Aeq", 7, [gattainNumrowAeq gattainNumvar])
+ Checkvector("fgoalattain", gattainBeq, "beq", 8, gattainNumrowAeq)
gattainBeq = gattainBeq(:)
end
@@ -248,17 +254,17 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
gattainUb = varargin(10)
end
- fgoalattainChecktype("fgoalattain", gattainLb, "lb", 9, "constant")
- fgoalattainChecktype("fgoalattain", gattainUb, "ub", 10, "constant")
+ Checktype("fgoalattain", gattainLb, "lb", 9, "constant")
+ Checktype("fgoalattain", gattainUb, "ub", 10, "constant")
// Check dimensions of lb and ub
if(gattainLb <> []) then
- fgoalattainCheckvector("fgoalattain", gattainLb, "lb", 9, gattainNumvar)
+ Checkvector("fgoalattain", gattainLb, "lb", 9, gattainNumvar)
gattainLb = gattainLb(:)
end
if(gattainUb <> []) then
- fgoalattainCheckvector("fgoalattain", gattainUb, "ub", 10, gattainNumvar)
+ Checkvector("fgoalattain", gattainUb, "ub", 10, gattainNumvar)
gattainUb = gattainUb(:)
end
@@ -274,7 +280,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
gattainNonlinfun = varargin(11)
end
- fgoalattainChecktype("fgoalattain", gattainNonlinfun, "nonlcon", 11, "function")
+ Checktype("fgoalattain", gattainNonlinfun, "nonlcon", 11, "function")
// initialisation of default options
if(gattainRhs < 12) then
@@ -313,12 +319,30 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
fgaCPU = gattainUserOptions(2*i); //Setting the Maximum CPU Time as per user entry
case "GradObj" then
- flag1=1;
- gattainFGrad = gattainUserOptions(2*i);
+ if (type(gattainUserOptions(2*i))==10) then
+ if (convstr(gattainUserOptions(2*i))=="off") then
+ flag1 = 0;
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized String %s entered for the option- %s."), "fgoalattain",gattainUserOptions(2*i), gattainUserOptions(2*i-1));
+ error(errmsg);
+ end
+ else
+ flag1 = 1;
+ gattainFGrad = gattainUserOptions(2*i);
+ end
case "GradCon" then
- flag2=1;
- gattainCGrad = gattainUserOptions(2*i);
+ if (type(gattainUserOptions(2*i))==10) then
+ if (convstr(gattainUserOptions(2*i))=="off") then
+ flag2 = 0;
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized String %s entered for the option- %s."), "fgoalattain",gattainUserOptions(2*i), gattainUserOptions(2*i-1));
+ error(errmsg);
+ end
+ else
+ flag2 = 1;
+ gattainCGrad = gattainUserOptions(2*i);
+ end
else
errmsg = msprintf(gettext("%s: Unrecognized gattainUserOptionseter name ''%s''."), "fminimax", gattainUserOptions(2*i-1));
@@ -326,7 +350,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
end
end
- // Checking if minmaxFGrad and minmaxCGrad are functions
+ // Checking if gattainFGrad and gattainCGrad are functions
if (flag1==1) then
if (type(gattainFGrad) ~= 11 & type(gattainFGrad) ~= 13) then
errmsg = msprintf(gettext("%s: Expected function for Gradient of Objective"), "fminimax");
diff --git a/macros/fgoalattainFunctions.bin b/macros/fgoalattainFunctions.bin
deleted file mode 100644
index eb72f4d..0000000
Binary files a/macros/fgoalattainFunctions.bin and /dev/null differ
diff --git a/macros/fgoalattainFunctions.sci b/macros/fgoalattainFunctions.sci
deleted file mode 100644
index 8745fa6..0000000
--- a/macros/fgoalattainFunctions.sci
+++ /dev/null
@@ -1,76 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2015 - IIT Bombay - FOSSEE
-//
-// Authors: Prajwala TM,Sheetal Shalini
-// Organization: FOSSEE, IIT Bombay
-// Email: prajwala.tm@gmail.com,sheetalsh456@gmail.com
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-
-// Define subsidiary functions used by fgoalattain
-
-// to check if the number of input arguments is equal to the numbers mentioned in the set
-function errmsg = fgoalattainCheckrhs ( funname , rhs , rhsset )
- errmsg = []
- if ( and(rhs <> rhsset) ) then
- rhsstr = strcat(string(rhsset)," ")
- errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while the number of expected input arguments should be in the set [%s]."), funname , rhs , rhsstr );
- error(errmsg)
- end
-endfunction
-
-// to check if the number of output arguments is equal to the numbers mentioned in the set, which is any number between 1 to 6 (both inclusive)
-function errmsg = fgoalattainChecklhs ( funname , lhs , lhsset )
-errmsg = []
- if ( and ( lhs <> lhsset ) ) then
- lhsstr = strcat(string(lhsset)," ")
- errmsg = msprintf(gettext("%s: Unexpected number of output arguments : %d provided while the expected number of output arguments should be in the set [%s]."), funname , lhs , lhsstr );
- error(errmsg)
- end
-endfunction
-
-// Generates an error if the given variable is not of expected type.
-function errmsg = fgoalattainChecktype ( funname , var , varname , ivar , expectedtype )
-errmsg = []
- if ( and ( typeof ( var ) <> expectedtype ) ) then
- strexp = """" + strcat(expectedtype,""" or """) + """"
- errmsg = msprintf(gettext("%s: Expected type [%s] for input argument %s at input #%d, but got ""%s"" instead."),funname, strexp, varname , ivar , typeof(var) );
- error(errmsg);
- end
-endfunction
-
-// Generates an error if the variable is not a vector.
-function errmsg = fgoalattainCheckvector ( funname , var , varname , ivar , nbval )
-errmsg = []
- nrows = size(var,"r")
- ncols = size(var,"c")
- if ( nrows <> 1 & ncols <> 1 ) then
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected a vector matrix for input argument %s at input #%d, but got [%s] instead."), funname, varname , ivar , strcomp );
- error(errmsg)
- end
- if ( ( nrows == 1 & ncols <> nbval ) | ( ncols == 1 & nrows <> nbval ) ) then
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected %d entries for input argument %s at input #%d, but current dimensions are [%s] instead."), funname, nbval , varname , ivar , strcomp );
- error(errmsg)
- end
-endfunction
-
-// Generates an error if the variable has not the required size.
-function errmsg = fgoalattainCheckdims ( funname , var , varname , ivar , matdims )
-[lhs,rhs]=argn()
- fgoalattainCheckrhs ( "fgoalattainCheckdims" , rhs , 5 )
- fgoalattainChecklhs ( "fgoalattainCheckdims" , lhs , [0 1] )
- errmsg = []
- if ( or ( size(var) <> matdims ) ) then
- strexp = strcat(string(matdims)," ")
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected size [%s] for input argument %s at input #%d, but got [%s] instead."), funname, strexp, varname , ivar , strcomp );
- error(errmsg)
- end
-endfunction
-
-
diff --git a/macros/fminimax.bin b/macros/fminimax.bin
deleted file mode 100644
index 4243455..0000000
Binary files a/macros/fminimax.bin and /dev/null differ
diff --git a/macros/fminimax.sci b/macros/fminimax.sci
index 5084475..04d0af6 100644
--- a/macros/fminimax.sci
+++ b/macros/fminimax.sci
@@ -160,15 +160,15 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
// f(4)= -x(1) - x(2);
// f(5)= x(1) + x(2) - 8;
// endfunction
+ //
// // The initial guess
// x0 = [0.1,0.1];
// // The expected solution : only 4 digits are guaranteed
- // //xopt = [4 4]
- // //fopt = [0 -64 -2 -8 0]
+ // xopt = [4 4]
+ // fopt = [0 -64 -2 -8 0]
// maxfopt = 0
// // Run fminimax
- // [xopt,fopt,maxfval,exitflag,output,lambda] = fminimax(myfun, x0)
- // // Press ENTER to continue
+ // [x,fval,maxfval,exitflag,output,lambda] = fminimax(myfun, x0)
//
// Examples
// // A case where we provide the gradient of the objective
@@ -181,11 +181,14 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
// f(4)= -x(1) - x(2);
// f(5)= x(1) + x(2) - 8;
// endfunction
+ //
// // Defining gradient of myfun
// function G = myfungrad(x)
// G = [ 4*x(1) - 48, -2*x(1), 1, -1, 1;
// 2*x(2) - 40, -6*x(2), 3, -1, 1; ]'
// endfunction
+ //
+ //
// // The nonlinear constraints and the Jacobian
// // matrix of the constraints
// function [c,ceq] = confun(x)
@@ -194,6 +197,8 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
// // No nonlinear equality constraints
// ceq=[]
// endfunction
+ //
+ //
// // Defining gradient of confungrad
// function [DC,DCeq] = cgrad(x)
// // DC(:,i) = gradient of the i-th constraint
@@ -207,34 +212,38 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
// ]'
// DCeq = []'
// endfunction
+ //
// // Test with both gradient of objective and gradient of constraints
// minimaxOptions = list("GradObj",myfungrad,"GradCon",cgrad);
// // The initial guess
// x0 = [0,10];
// // The expected solution : only 4 digits are guaranteed
- // //xopt = [0.92791 7.93551]
- // //fopt = [6.73443 -189.778 6.73443 -8.86342 0.86342]
+ // xopt = [0.92791 7.93551]
+ // fopt = [6.73443 -189.778 6.73443 -8.86342 0.86342]
// maxfopt = 6.73443
// // Run fminimax
- // [xopt,fopt,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+ // [x,fval,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+ //
+ //
// Authors
// Animesh Baranawal
+ //
// Check number of input and output arguments
[minmaxLhs,minmaxRhs] = argn()
- fminimaxCheckrhs("fminimax", minmaxRhs, [2 4 6 8 9 10])
- fminimaxChecklhs("fminimax", minmaxLhs, 1:7)
+ Checkrhs("fminimax", minmaxRhs, [2 4 6 8 9 10])
+ Checklhs("fminimax", minmaxLhs, 1:7)
// Proper initialisation of objective function
minmaxObjfun = varargin(1)
- fminimaxChecktype("fminimax", minmaxObjfun, "minmaxObjfun", 1, "function")
+ Checktype("fminimax", minmaxObjfun, "minmaxObjfun", 1, "function")
// Proper initialisation of starting point
minmaxStartpoint = varargin(2)
- fminimaxChecktype("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, "constant")
+ Checktype("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, "constant")
minmaxNumvar = size(minmaxStartpoint,"*")
- fminimaxCheckvector("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, minmaxNumvar)
+ Checkvector("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, minmaxNumvar)
minmaxStartpoint = minmaxStartpoint(:)
// Proper initialisation of A and b
@@ -246,8 +255,8 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxB = varargin(4)
end
- fminimaxChecktype("fminimax", minmaxA, "A", 3, "constant")
- fminimaxChecktype("fminimax", minmaxB, "b", 4, "constant")
+ Checktype("fminimax", minmaxA, "A", 3, "constant")
+ Checktype("fminimax", minmaxB, "b", 4, "constant")
// Check if A and b of proper dimensions
if(minmaxA <> [] & minmaxB == []) then
@@ -262,8 +271,8 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxNumrowA = size(minmaxA,"r")
if(minmaxA <> []) then
- fminimaxCheckdims("fminimax", minmaxA, "A", 3, [minmaxNumrowA minmaxNumvar])
- fminimaxCheckvector("fminimax", minmaxB, "b", 4, minmaxNumrowA)
+ Checkdims("fminimax", minmaxA, "A", 3, [minmaxNumrowA minmaxNumvar])
+ Checkvector("fminimax", minmaxB, "b", 4, minmaxNumrowA)
minmaxB = minmaxB(:)
end
@@ -276,8 +285,8 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxBeq = varargin(6)
end
- fminimaxChecktype("fminimax", minmaxAeq, "Aeq", 5, "constant")
- fminimaxChecktype("fminimax", minmaxBeq, "beq", 6, "constant")
+ Checktype("fminimax", minmaxAeq, "Aeq", 5, "constant")
+ Checktype("fminimax", minmaxBeq, "beq", 6, "constant")
// Check if Aeq and beq of proper dimensions
if(minmaxAeq <> [] & minmaxBeq == []) then
@@ -292,8 +301,8 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxNumrowAeq = size(minmaxAeq,"r")
if(minmaxAeq <> []) then
- fminimaxCheckdims("fminimax", minmaxAeq, "Aeq", 5, [minmaxNumrowAeq minmaxNumvar])
- fminimaxCheckvector("fminimax", minmaxBeq, "beq", 6, minmaxNumrowAeq)
+ Checkdims("fminimax", minmaxAeq, "Aeq", 5, [minmaxNumrowAeq minmaxNumvar])
+ Checkvector("fminimax", minmaxBeq, "beq", 6, minmaxNumrowAeq)
minmaxBeq = minmaxBeq(:)
end
@@ -306,17 +315,17 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxUb = varargin(8)
end
- fminimaxChecktype("fminimax", minmaxLb, "lb", 7, "constant")
- fminimaxChecktype("fminimax", minmaxUb, "ub", 8, "constant")
+ Checktype("fminimax", minmaxLb, "lb", 7, "constant")
+ Checktype("fminimax", minmaxUb, "ub", 8, "constant")
// Check dimensions of minmaxLb and minmaxUb
if(minmaxLb <> []) then
- fminimaxCheckvector("fminimax", minmaxLb, "lb", 7, minmaxNumvar)
+ Checkvector("fminimax", minmaxLb, "lb", 7, minmaxNumvar)
minmaxLb = minmaxLb(:)
end
if(minmaxUb <> []) then
- fminimaxCheckvector("fminimax", minmaxUb, "ub", 8, minmaxNumvar)
+ Checkvector("fminimax", minmaxUb, "ub", 8, minmaxNumvar)
minmaxUb = minmaxUb(:)
end
@@ -337,7 +346,7 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxNonlinfun = t
end
- fminimaxChecktype("fminimax", minmaxNonlinfun, "nonlinfun", 9, "function")
+ Checktype("fminimax", minmaxNonlinfun, "nonlinfun", 9, "function")
//To check, Whether minimaxOptions is been entered by user
if ( minmaxRhs<10 ) then
@@ -376,12 +385,30 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
minmaxCPU = minmaxUserOptions(2*i); //Setting the Maximum CPU Time as per user entry
case "GradObj" then
- flag1=1;
- minmaxFGrad = minmaxUserOptions(2*i);
+ if (type(minmaxUserOptions(2*i))==10) then
+ if (convstr(minmaxUserOptions(2*i))=="off") then
+ flag1 = 0;
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized String %s entered for the option- %s."), "fminimax",minmaxUserOptions(2*i), minmaxUserOptions(2*i-1));
+ error(errmsg);
+ end
+ else
+ flag1 = 1;
+ minmaxFGrad = minmaxUserOptions(2*i);
+ end
case "GradCon" then
- flag2=1;
- minmaxCGrad = minmaxUserOptions(2*i);
+ if (type(minmaxUserOptions(2*i))==10) then
+ if (convstr(minmaxUserOptions(2*i))=="off") then
+ flag2 = 0;
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized String %s entered for the option- %s."), "fminimax",minmaxUserOptions(2*i), minmaxUserOptions(2*i-1));
+ error(errmsg);
+ end
+ else
+ flag2 = 1;
+ minmaxCGrad = minmaxUserOptions(2*i);
+ end
else
errmsg = msprintf(gettext("%s: Unrecognized minmaxUserOptionseter name ''%s''."), "fminimax", minmaxUserOptions(2*i-1));
@@ -488,6 +515,27 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
end
endfunction
+ // disp(minmaxStartpoint)
+ // a = minmaxObjfun(minmaxStartpoint)
+ // disp(a)
+ // disp(newObjfun(minmaxStartpoint))
+ // disp(minmaxA)
+ // disp(minmaxB)
+ // disp(minmaxAeq)
+ // disp(minmaxBeq)
+ // disp(minmaxLb)
+ // disp(minmaxUb)
+ // [a,b] = minmaxNonlinfun(minmaxStartpoint)
+ // disp(a)
+ // disp(b)
+ // [a,b] = newNonlinfun(minmaxStartpoint)
+ // disp(a)
+ // disp(b)
+ // [a,b] = newCGrad(minmaxStartpoint)
+ // disp(a)
+ // disp(b)
+ // disp(newFGrad(minmaxStartpoint))
+
// to be passed as minimaxOptions to fmincon
if(flag1 == 1 | flag2 == 1) then
minmaxPassOptions = list("MaxIter", minmaxMaxIter, "CpuTime", minmaxCPU, "GradCon", newCGrad)
diff --git a/macros/fminimaxCheckdims.bin b/macros/fminimaxCheckdims.bin
deleted file mode 100644
index be1ed46..0000000
Binary files a/macros/fminimaxCheckdims.bin and /dev/null differ
diff --git a/macros/fminimaxCheckdims.sci b/macros/fminimaxCheckdims.sci
deleted file mode 100644
index 83cb5b5..0000000
--- a/macros/fminimaxCheckdims.sci
+++ /dev/null
@@ -1,56 +0,0 @@
-
-// Copyright (C) 2010 - DIGITEO - Michael Baudin
-//
-// This file must be used under the terms of the GNU LGPL license.
-
-function errmsg = fminimaxCheckdims ( funname , var , varname , ivar , matdims )
- // Generates an error if the variable has not the required size.
- //
- // Calling Sequence
- // errmsg = fminimaxCheckdims ( funname , var , varname , ivar , matdims )
- //
- // Parameters
- // funname : a 1 x 1 matrix of strings, the name of the calling function.
- // var : a 1 x 1 matrix of valid Scilab data type, the variable
- // varname : a 1 x 1 matrix of string, the name of the variable
- // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
- // matdims : 1 x 2 matrix of floating point integers, the number of rows, columns for the variable #ivar
- // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
- //
- // Description
- // This function is designed to be used to design functions where
- // the input argument has a known shape.
- // This function cannot be use when var is a function, or more
- // generally, for any input argument for which the size function
- // does not work.
- // Last update : 05/08/2010.
- //
- // Examples
- // // The function takes a 2 x 3 matrix of doubles.
- // function y = myfunction ( x )
- // fminimaxCheckdims ( "myfunction" , x , "x" , 1 , [2 3] )
- // y = x
- // endfunction
- // // Calling sequences which work
- // y = myfunction ( ones(2,3) )
- // y = myfunction ( zeros(2,3) )
- // // Calling sequences which generate an error
- // y = myfunction ( ones(1,3) )
- // y = myfunction ( zeros(2,4) )
- //
- // Authors
- // Michael Baudin - 2010 - DIGITEO
- //
-
- [lhs,rhs]=argn()
- fminimaxCheckrhs ( "fminimaxCheckdims" , rhs , 5 )
- fminimaxChecklhs ( "fminimaxCheckdims" , lhs , [0 1] )
-
- errmsg = []
- if ( or ( size(var) <> matdims ) ) then
- strexp = strcat(string(matdims)," ")
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected size [%s] for input argument %s at input #%d, but got [%s] instead."), funname, strexp, varname , ivar , strcomp );
- error(errmsg)
- end
-endfunction
diff --git a/macros/fminimaxChecklhs.bin b/macros/fminimaxChecklhs.bin
deleted file mode 100644
index 7889084..0000000
Binary files a/macros/fminimaxChecklhs.bin and /dev/null differ
diff --git a/macros/fminimaxChecklhs.sci b/macros/fminimaxChecklhs.sci
deleted file mode 100644
index 78e4013..0000000
--- a/macros/fminimaxChecklhs.sci
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2010 - DIGITEO - Michael Baudin
-//
-// This file must be used under the terms of the GNU LGPL license.
-
-function errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
- // Generates an error if the number of LHS is not in given set.
- //
- // Calling Sequence
- // errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
- //
- // Parameters
- // funname : a 1 x 1 matrix of strings, the name of the calling function.
- // lhs : a 1 x 1 matrix of floating point integers, the actual number of output arguments
- // lhsset : a 1 x n or n x 1 matrix of floating point integers, the authorized number of output arguments
- // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
- //
- // Description
- // This function is designed to be used to design functions with
- // variable number of output arguments.
- // Notice that it is useless to call this function if the
- // function definition does not use the varargout statement.
- // Notice that a function as a minimum of 1 output argument.
- // Last update : 29/07/2010.
- //
- // Examples
- // // The function takes 3 input arguments and 1/2 output arguments
- // function varargout = myfunction ( x1 , x2 , x3 )
- // [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , 3 : 3 )
- // fminimaxChecklhs ( "myfunction" , lhs , 1 : 2 )
- // y1 = x1 + x2
- // y2 = x2 + x3
- // varargout(1) = y1
- // if ( lhs == 2 ) then
- // varargout(2) = y2
- // end
- // endfunction
- // // Calling sequences which work
- // myfunction ( 1 , 2 , 3 )
- // y1 = myfunction ( 1 , 2 , 3 )
- // [ y1 , y2 ] = myfunction ( 1 , 2 , 3 )
- // // Calling sequences which generate an error
- // [ y1 , y2 , y3 ] = myfunction ( 1 , 2 , 3 )
- //
- // // The function takes 1 or 3 output arguments, but not 2
- // function varargout = myfunction ( x1 , x2 , x3 )
- // [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , 3 : 3 )
- // fminimaxChecklhs ( "myfunction" , lhs , [1 3] )
- // y1 = x1 + x2
- // y2 = x2 + x3
- // y3 = x1 + x3
- // varargout(1) = y1
- // if ( lhs == 3 ) then
- // varargout(2) = y2
- // varargout(3) = y3
- // end
- // endfunction
- // // Calling sequences which work
- // myfunction ( 1 , 2 , 3 )
- // y1 = myfunction ( 1 , 2 , 3 )
- // [ y1 , y2 , y3 ] = myfunction ( 1 , 2 , 3 )
- // // Calling sequences which generate an error
- // [y1 , y2] = myfunction ( 1 , 2 , 3 )
- //
- // Authors
- // Michael Baudin - 2010 - DIGITEO
- //
-
- errmsg = []
- if ( and ( lhs <> lhsset ) ) then
- lhsstr = strcat(string(lhsset)," ")
- errmsg = msprintf(gettext("%s: Unexpected number of output arguments : %d provided while the expected number of output arguments should be in the set [%s]."), funname , lhs , lhsstr );
- error(errmsg)
- end
-endfunction
-
-
-
diff --git a/macros/fminimaxCheckrhs.bin b/macros/fminimaxCheckrhs.bin
deleted file mode 100644
index 6b190f7..0000000
Binary files a/macros/fminimaxCheckrhs.bin and /dev/null differ
diff --git a/macros/fminimaxCheckrhs.sci b/macros/fminimaxCheckrhs.sci
deleted file mode 100644
index 7877153..0000000
--- a/macros/fminimaxCheckrhs.sci
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (C) 2010 - DIGITEO - Michael Baudin
-//
-// This file must be used under the terms of the GNU LGPL license.
-
-function errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
- // Generates an error if the number of RHS is not in given set.
- //
- // Calling Sequence
- // errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
- //
- // Parameters
- // funname : a 1 x 1 matrix of strings, the name of the calling function.
- // rhs : a 1 x 1 matrix of floating point integers, the actual number of input arguments
- // rhsset : a 1 x n or n x 1 matrix of floating point integers, the authorized number of input arguments
- // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
- //
- // Description
- // This function is designed to be used to design functions with
- // variable number of input arguments.
- // Notice that it is useless to call this function if the
- // function definition does not use the varargin statement.
- // Last update : 05/08/2010.
- // Last update : 29/07/2010.
- //
- // Examples
- // // The function takes 2/3 input arguments and 1 output arguments
- // function y = myfunction ( varargin )
- // [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , 2:3 )
- // fminimaxChecklhs ( "myfunction" , lhs , 1 )
- // x1 = varargin(1)
- // x2 = varargin(2)
- // if ( rhs >= 3 ) then
- // x3 = varargin(3)
- // else
- // x3 = 2
- // end
- // y = x1 + x2 + x3
- // endfunction
- // // Calling sequences which work
- // y = myfunction ( 1 , 2 )
- // y = myfunction ( 1 , 2 , 3 )
- // // Calling sequences which generate an error
- // y = myfunction ( 1 )
- // y = myfunction ( 1 , 2 , 3 , 4 )
- //
- // // The function takes 2 or 4 input arguments, but not 3
- // function y = myfunction ( varargin )
- // [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , [2 4] )
- // fminimaxChecklhs ( "myfunction" , lhs , 1 )
- // x1 = varargin(1)
- // x2 = varargin(2)
- // if ( rhs >= 3 ) then
- // x3 = varargin(3)
- // x4 = varargin(4)
- // else
- // x3 = 2
- // x4 = 3
- // end
- // y = x1 + x2 + x3 + x4
- // endfunction
- // // Calling sequences which work
- // y = myfunction ( 1 , 2 )
- // y = myfunction ( 1 , 2 , 3 , 4 )
- // // Calling sequences which generate an error
- // y = myfunction ( 1 )
- // y = myfunction ( 1 , 2 , 3 )
- // y = myfunction ( 1 , 2 , 3 , 4, 5 )
- //
- // // The function takes 2 input arguments and 0/1 output arguments.
- // // Notice that if the checkrhs function is not called,
- // // the variable x2 might be used from the user's context,
- // // that is, if the caller has defined the variable x2, it
- // // is used in the callee.
- // // Here, we want to avoid this.
- // function y = myfunction ( x1 , x2 )
- // [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , 2 )
- // fminimaxChecklhs ( "myfunction" , lhs , [0 1] )
- // y = x1 + x2
- // endfunction
- // // Calling sequences which work
- // y = myfunction ( 1 , 2 )
- // // Calling sequences which generate an error
- // y = myfunction ( 1 )
- // y = myfunction ( 1 , 2 , 3 )
- //
- // Authors
- // Michael Baudin - 2010 - DIGITEO
- //
-
- errmsg = []
- if ( and(rhs <> rhsset) ) then
- rhsstr = strcat(string(rhsset)," ")
- errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while the number of expected input arguments should be in the set [%s]."), funname , rhs , rhsstr );
- error(errmsg)
- end
-endfunction
-
-
-
diff --git a/macros/fminimaxChecktype.bin b/macros/fminimaxChecktype.bin
deleted file mode 100644
index 4f42fe0..0000000
Binary files a/macros/fminimaxChecktype.bin and /dev/null differ
diff --git a/macros/fminimaxChecktype.sci b/macros/fminimaxChecktype.sci
deleted file mode 100644
index 48514b6..0000000
--- a/macros/fminimaxChecktype.sci
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2010 - DIGITEO - Michael Baudin
-//
-// This file must be used under the terms of the GNU LGPL license.
-
-function errmsg = fminimaxChecktype ( funname , var , varname , ivar , expectedtype )
- // Generates an error if the given variable is not of expected type.
- //
- // Calling Sequence
- // errmsg = fminimaxChecktype ( funname , var , varname , ivar , expectedtype )
- //
- // Parameters
- // funname : a 1 x 1 matrix of strings, the name of the calling function.
- // var : a 1 x 1 matrix of valid Scilab data type, the variable
- // varname : a 1 x 1 matrix of string, the name of the variable
- // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
- // expectedtype : a n x 1 or 1 x n matrix of strings, the available types for the variable #ivar
- // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
- //
- // Description
- // This function is designed to be used to design functions with
- // input arguments with variable type.
- // We use the typeof function to compute the type of the variable:
- // see help typeof to get the list of all available values for expectedtype.
- // Last update : 29/07/2010.
- //
- // Examples
- // // The function takes a string argument.
- // function myfunction ( x )
- // fminimaxChecktype ( "myfunction" , x , "x" , 1 , "string" )
- // disp("This is a string")
- // endfunction
- // // Calling sequences which work
- // myfunction ( "Scilab" )
- // // Calling sequences which generate an error
- // myfunction ( 123456 )
- //
- // // The function takes a string or a matrix of doubles argument.
- // function myfunction ( x )
- // fminimaxChecktype ( "myfunction" , x , "x" , 1 , [ "string" "constant" ] )
- // if ( typeof(x) == "string" ) then
- // disp("This is a matrix of strings")
- // else
- // disp("This is a matrix of doubles")
- // end
- // endfunction
- // // Calling sequences which work
- // myfunction ( "Scilab" )
- // myfunction ( 123456 )
- // // Calling sequences which generate an error
- // myfunction ( uint8(2) )
- //
- // Authors
- // Michael Baudin - 2010 - DIGITEO
- //
-
- errmsg = []
- if ( and ( typeof ( var ) <> expectedtype ) ) then
- strexp = """" + strcat(expectedtype,""" or """) + """"
- errmsg = msprintf(gettext("%s: Expected type [%s] for input argument %s at input #%d, but got ""%s"" instead."),funname, strexp, varname , ivar , typeof(var) );
- error(errmsg);
- end
-endfunction
-
-
-
diff --git a/macros/fminimaxCheckvector.bin b/macros/fminimaxCheckvector.bin
deleted file mode 100644
index 28af2c5..0000000
Binary files a/macros/fminimaxCheckvector.bin and /dev/null differ
diff --git a/macros/fminimaxCheckvector.sci b/macros/fminimaxCheckvector.sci
deleted file mode 100644
index 87c8553..0000000
--- a/macros/fminimaxCheckvector.sci
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2010 - DIGITEO - Michael Baudin
-//
-// This file must be used under the terms of the GNU LGPL license.
-
-function errmsg = fminimaxCheckvector ( funname , var , varname , ivar , nbval )
- // Generates an error if the variable is not a vector.
- //
- // Calling Sequence
- // errmsg = fminimaxCheckvector ( funname , var , varname , ivar )
- //
- // Parameters
- // funname : a 1 x 1 matrix of strings, the name of the calling function.
- // var : a 1 x 1 matrix of valid Scilab data type, the variable
- // varname : a 1 x 1 matrix of string, the name of the variable
- // ivar : a 1 x 1 matrix of floating point integers, the index of the input argument in the calling sequence
- // nbval : a 1 x 1 matrix of floating point integers, the number of entries in the vector.
- // errmsg : a 1 x 1 matrix of strings, the error message. If there was no error, the error message is the empty matrix.
- //
- // Description
- // This function is designed to be used to design functions where
- // the input argument is a vector, that is, a matrix for which
- // nrows == 1 or ncols == 1.
- // This function cannot be use when var is a function, or more
- // generally, for any input argument for which the size function
- // does not work.
- //
- // Examples
- // // The function takes a vector of 3 doubles.
- // function y = myfunction ( x )
- // fminimaxCheckvector ( "myfunction" , x , "x" , 1 , 3 )
- // y = x
- // endfunction
- // // Calling sequences which work
- // y = myfunction ( ones(1,3) )
- // y = myfunction ( zeros(3,1) )
- // // Calling sequences which generate an error
- // // The following are not vectors
- // y = myfunction ( ones(2,3) )
- // y = myfunction ( zeros(3,2) )
- // // The following have the wrong number of entries
- // y = myfunction ( ones(1,3) )
- //
- // Authors
- // Michael Baudin - 2010 - DIGITEO
- //
-
- errmsg = []
- nrows = size(var,"r")
- ncols = size(var,"c")
- if ( nrows <> 1 & ncols <> 1 ) then
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected a vector matrix for input argument %s at input #%d, but got [%s] instead."), funname, varname , ivar , strcomp );
- error(errmsg)
- end
- if ( ( nrows == 1 & ncols <> nbval ) | ( ncols == 1 & nrows <> nbval ) ) then
- strcomp = strcat(string(size(var))," ")
- errmsg = msprintf(gettext("%s: Expected %d entries for input argument %s at input #%d, but current dimensions are [%s] instead."), funname, nbval , varname , ivar , strcomp );
- error(errmsg)
- end
-endfunction
-
-
-
--
cgit