summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--macros/Checkdims.sci (renamed from macros/fminimaxCheckdims.sci)10
-rw-r--r--macros/Checklhs.sci (renamed from macros/fminimaxChecklhs.sci)12
-rw-r--r--macros/Checkrhs.sci (renamed from macros/fminimaxCheckrhs.sci)16
-rw-r--r--macros/Checktype.sci (renamed from macros/fminimaxChecktype.sci)8
-rw-r--r--macros/Checkvector.sci (renamed from macros/fminimaxCheckvector.sci)6
-rw-r--r--macros/fgoalattain.binbin79072 -> 0 bytes
-rw-r--r--macros/fgoalattain.sci88
-rw-r--r--macros/fgoalattainFunctions.binbin10432 -> 0 bytes
-rw-r--r--macros/fgoalattainFunctions.sci76
-rw-r--r--macros/fminimax.binbin85724 -> 0 bytes
-rw-r--r--macros/fminimax.sci106
-rw-r--r--macros/fminimaxCheckdims.binbin8332 -> 0 bytes
-rw-r--r--macros/fminimaxChecklhs.binbin10472 -> 0 bytes
-rw-r--r--macros/fminimaxCheckrhs.binbin13076 -> 0 bytes
-rw-r--r--macros/fminimaxChecktype.binbin9252 -> 0 bytes
-rw-r--r--macros/fminimaxCheckvector.binbin9760 -> 0 bytes
16 files changed, 159 insertions, 163 deletions
diff --git a/macros/fminimaxCheckdims.sci b/macros/Checkdims.sci
index 83cb5b5..0936222 100644
--- a/macros/fminimaxCheckdims.sci
+++ b/macros/Checkdims.sci
@@ -3,11 +3,11 @@
//
// This file must be used under the terms of the GNU LGPL license.
-function errmsg = fminimaxCheckdims ( funname , var , varname , ivar , matdims )
+function errmsg = Checkdims ( 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 )
+ // errmsg = Checkdims ( funname , var , varname , ivar , matdims )
//
// Parameters
// funname : a 1 x 1 matrix of strings, the name of the calling function.
@@ -28,7 +28,7 @@ function errmsg = fminimaxCheckdims ( funname , var , varname , ivar , matdims )
// Examples
// // The function takes a 2 x 3 matrix of doubles.
// function y = myfunction ( x )
- // fminimaxCheckdims ( "myfunction" , x , "x" , 1 , [2 3] )
+ // Checkdims ( "myfunction" , x , "x" , 1 , [2 3] )
// y = x
// endfunction
// // Calling sequences which work
@@ -43,8 +43,8 @@ function errmsg = fminimaxCheckdims ( funname , var , varname , ivar , matdims )
//
[lhs,rhs]=argn()
- fminimaxCheckrhs ( "fminimaxCheckdims" , rhs , 5 )
- fminimaxChecklhs ( "fminimaxCheckdims" , lhs , [0 1] )
+ Checkrhs ( funname , rhs , 5 )
+ Checklhs ( funname , lhs , [0 1] )
errmsg = []
if ( or ( size(var) <> matdims ) ) then
diff --git a/macros/fminimaxChecklhs.sci b/macros/Checklhs.sci
index 78e4013..fd47b0c 100644
--- a/macros/fminimaxChecklhs.sci
+++ b/macros/Checklhs.sci
@@ -2,11 +2,11 @@
//
// This file must be used under the terms of the GNU LGPL license.
-function errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
+function errmsg = Checklhs ( funname , lhs , lhsset )
// Generates an error if the number of LHS is not in given set.
//
// Calling Sequence
- // errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
+ // errmsg = Checklhs ( funname , lhs , lhsset )
//
// Parameters
// funname : a 1 x 1 matrix of strings, the name of the calling function.
@@ -26,8 +26,8 @@ function errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
// // 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 )
+ // Checkrhs ( "myfunction" , rhs , 3 : 3 )
+ // Checklhs ( "myfunction" , lhs , 1 : 2 )
// y1 = x1 + x2
// y2 = x2 + x3
// varargout(1) = y1
@@ -45,8 +45,8 @@ function errmsg = fminimaxChecklhs ( funname , lhs , lhsset )
// // 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] )
+ // Checkrhs ( "myfunction" , rhs , 3 : 3 )
+ // Checklhs ( "myfunction" , lhs , [1 3] )
// y1 = x1 + x2
// y2 = x2 + x3
// y3 = x1 + x3
diff --git a/macros/fminimaxCheckrhs.sci b/macros/Checkrhs.sci
index 7877153..6b5cf5b 100644
--- a/macros/fminimaxCheckrhs.sci
+++ b/macros/Checkrhs.sci
@@ -2,11 +2,11 @@
//
// This file must be used under the terms of the GNU LGPL license.
-function errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
+function errmsg = Checkrhs ( funname , rhs , rhsset )
// Generates an error if the number of RHS is not in given set.
//
// Calling Sequence
- // errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
+ // errmsg = Checkrhs ( funname , rhs , rhsset )
//
// Parameters
// funname : a 1 x 1 matrix of strings, the name of the calling function.
@@ -26,8 +26,8 @@ function errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
// // 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 )
+ // Checkrhs ( "myfunction" , rhs , 2:3 )
+ // Checklhs ( "myfunction" , lhs , 1 )
// x1 = varargin(1)
// x2 = varargin(2)
// if ( rhs >= 3 ) then
@@ -47,8 +47,8 @@ function errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
// // 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 )
+ // Checkrhs ( "myfunction" , rhs , [2 4] )
+ // Checklhs ( "myfunction" , lhs , 1 )
// x1 = varargin(1)
// x2 = varargin(2)
// if ( rhs >= 3 ) then
@@ -76,8 +76,8 @@ function errmsg = fminimaxCheckrhs ( funname , rhs , rhsset )
// // Here, we want to avoid this.
// function y = myfunction ( x1 , x2 )
// [lhs, rhs] = argn()
- // fminimaxCheckrhs ( "myfunction" , rhs , 2 )
- // fminimaxChecklhs ( "myfunction" , lhs , [0 1] )
+ // Checkrhs ( "myfunction" , rhs , 2 )
+ // Checklhs ( "myfunction" , lhs , [0 1] )
// y = x1 + x2
// endfunction
// // Calling sequences which work
diff --git a/macros/fminimaxChecktype.sci b/macros/Checktype.sci
index 48514b6..3f50fa2 100644
--- a/macros/fminimaxChecktype.sci
+++ b/macros/Checktype.sci
@@ -2,11 +2,11 @@
//
// This file must be used under the terms of the GNU LGPL license.
-function errmsg = fminimaxChecktype ( funname , var , varname , ivar , expectedtype )
+function errmsg = Checktype ( 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 )
+ // errmsg = Checktype ( funname , var , varname , ivar , expectedtype )
//
// Parameters
// funname : a 1 x 1 matrix of strings, the name of the calling function.
@@ -26,7 +26,7 @@ function errmsg = fminimaxChecktype ( funname , var , varname , ivar , expectedt
// Examples
// // The function takes a string argument.
// function myfunction ( x )
- // fminimaxChecktype ( "myfunction" , x , "x" , 1 , "string" )
+ // Checktype ( "myfunction" , x , "x" , 1 , "string" )
// disp("This is a string")
// endfunction
// // Calling sequences which work
@@ -36,7 +36,7 @@ function errmsg = fminimaxChecktype ( funname , var , varname , ivar , expectedt
//
// // The function takes a string or a matrix of doubles argument.
// function myfunction ( x )
- // fminimaxChecktype ( "myfunction" , x , "x" , 1 , [ "string" "constant" ] )
+ // Checktype ( "myfunction" , x , "x" , 1 , [ "string" "constant" ] )
// if ( typeof(x) == "string" ) then
// disp("This is a matrix of strings")
// else
diff --git a/macros/fminimaxCheckvector.sci b/macros/Checkvector.sci
index 87c8553..76bdcc6 100644
--- a/macros/fminimaxCheckvector.sci
+++ b/macros/Checkvector.sci
@@ -2,11 +2,11 @@
//
// This file must be used under the terms of the GNU LGPL license.
-function errmsg = fminimaxCheckvector ( funname , var , varname , ivar , nbval )
+function errmsg = Checkvector ( funname , var , varname , ivar , nbval )
// Generates an error if the variable is not a vector.
//
// Calling Sequence
- // errmsg = fminimaxCheckvector ( funname , var , varname , ivar )
+ // errmsg = Checkvector ( funname , var , varname , ivar )
//
// Parameters
// funname : a 1 x 1 matrix of strings, the name of the calling function.
@@ -27,7 +27,7 @@ function errmsg = fminimaxCheckvector ( funname , var , varname , ivar , nbval )
// Examples
// // The function takes a vector of 3 doubles.
// function y = myfunction ( x )
- // fminimaxCheckvector ( "myfunction" , x , "x" , 1 , 3 )
+ // Checkvector ( "myfunction" , x , "x" , 1 , 3 )
// y = x
// endfunction
// // Calling sequences which work
diff --git a/macros/fgoalattain.bin b/macros/fgoalattain.bin
deleted file mode 100644
index e4d0024..0000000
--- a/macros/fgoalattain.bin
+++ /dev/null
Binary files 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)
// <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
// </itemizedlist>
//
- // 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)
// <programlisting>
// [c, ceq] = confun(x)
// </programlisting>
- // 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)
// </itemizedlist>
//
// 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
--- a/macros/fgoalattainFunctions.bin
+++ /dev/null
Binary files 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
--- a/macros/fminimax.bin
+++ /dev/null
Binary files 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
--- a/macros/fminimaxCheckdims.bin
+++ /dev/null
Binary files differ
diff --git a/macros/fminimaxChecklhs.bin b/macros/fminimaxChecklhs.bin
deleted file mode 100644
index 7889084..0000000
--- a/macros/fminimaxChecklhs.bin
+++ /dev/null
Binary files differ
diff --git a/macros/fminimaxCheckrhs.bin b/macros/fminimaxCheckrhs.bin
deleted file mode 100644
index 6b190f7..0000000
--- a/macros/fminimaxCheckrhs.bin
+++ /dev/null
Binary files differ
diff --git a/macros/fminimaxChecktype.bin b/macros/fminimaxChecktype.bin
deleted file mode 100644
index 4f42fe0..0000000
--- a/macros/fminimaxChecktype.bin
+++ /dev/null
Binary files differ
diff --git a/macros/fminimaxCheckvector.bin b/macros/fminimaxCheckvector.bin
deleted file mode 100644
index 28af2c5..0000000
--- a/macros/fminimaxCheckvector.bin
+++ /dev/null
Binary files differ