summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarpreet2016-01-25 01:05:02 +0530
committerHarpreet2016-01-25 01:05:02 +0530
commita2d9c2bfd6eb83d1a494821176388eb312d08254 (patch)
tree611fba3b340ba48b9d9d7435ce2f29b1ce0c12fa
parentdd3d72ae2cdb43311b4e501966f09694bbd3e505 (diff)
downloadFOSSEE-Optimization-toolbox-a2d9c2bfd6eb83d1a494821176388eb312d08254.tar.gz
FOSSEE-Optimization-toolbox-a2d9c2bfd6eb83d1a494821176388eb312d08254.tar.bz2
FOSSEE-Optimization-toolbox-a2d9c2bfd6eb83d1a494821176388eb312d08254.zip
functions added
-rw-r--r--demos/exmip1.mps70
-rw-r--r--demos/fgoalattain.dem.sce26
-rw-r--r--demos/fminbnd.dem.sce54
-rw-r--r--demos/fmincon.dem.sce155
-rw-r--r--demos/fminimax.dem.sce73
-rw-r--r--demos/fminunc.dem.sce61
-rwxr-xr-xdemos/linprog.dem.sce64
-rw-r--r--help/en_US/fgoalattain.xml232
-rw-r--r--help/en_US/fminbnd.xml197
-rw-r--r--help/en_US/fmincon.xml334
-rw-r--r--help/en_US/fminimax.xml293
-rw-r--r--help/en_US/fminunc.xml196
-rwxr-xr-xhelp/en_US/linprog.xml222
-rw-r--r--help/en_US/master_help.xml10
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/DOCSbin7090 -> 8232 bytes
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TABbin781 -> 922 bytes
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETSbin266 -> 296 bytes
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONSbin34613 -> 43830 bytes
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA2
-rw-r--r--help/en_US/scilab_en_US_help/JavaHelpSearch/TMAPbin16384 -> 18432 bytes
-rw-r--r--help/en_US/scilab_en_US_help/_LaTeX_fgoalattain.xml_1.pngbin0 -> 4343 bytes
-rw-r--r--help/en_US/scilab_en_US_help/_LaTeX_fminbnd.xml_1.pngbin0 -> 1792 bytes
-rw-r--r--help/en_US/scilab_en_US_help/_LaTeX_fmincon.xml_1.pngbin0 -> 3781 bytes
-rw-r--r--help/en_US/scilab_en_US_help/_LaTeX_fminunc.xml_1.pngbin0 -> 714 bytes
-rw-r--r--help/en_US/scilab_en_US_help/_LaTeX_linprog.xml_1.pngbin0 -> 2509 bytes
-rw-r--r--help/en_US/scilab_en_US_help/fgoalattain.html195
-rw-r--r--help/en_US/scilab_en_US_help/fminbnd.html174
-rw-r--r--help/en_US/scilab_en_US_help/fmincon.html302
-rw-r--r--help/en_US/scilab_en_US_help/fminunc.html178
-rw-r--r--help/en_US/scilab_en_US_help/index.html32
-rw-r--r--help/en_US/scilab_en_US_help/jhelpmap.jhm5
-rw-r--r--help/en_US/scilab_en_US_help/jhelptoc.xml5
-rw-r--r--help/en_US/scilab_en_US_help/linprog.html188
-rw-r--r--help/en_US/scilab_en_US_help/lsqlin.html4
-rw-r--r--help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html32
-rw-r--r--jar/scilab_en_US_help.jarbin208569 -> 252170 bytes
-rw-r--r--macros/fgoalattain.binbin0 -> 79236 bytes
-rw-r--r--macros/fgoalattain.sci514
-rw-r--r--macros/fgoalattainFunctions.binbin0 -> 10432 bytes
-rw-r--r--macros/fgoalattainFunctions.sci76
-rw-r--r--macros/fminbnd.binbin0 -> 53656 bytes
-rw-r--r--macros/fminbnd.sci356
-rw-r--r--macros/fmincon.binbin0 -> 149436 bytes
-rw-r--r--macros/fmincon.sci928
-rw-r--r--macros/fminimax.binbin0 -> 85668 bytes
-rw-r--r--macros/fminimax.sci511
-rw-r--r--macros/fminimaxCheckdims.binbin0 -> 8332 bytes
-rw-r--r--macros/fminimaxCheckdims.sci56
-rw-r--r--macros/fminimaxChecklhs.binbin0 -> 10472 bytes
-rw-r--r--macros/fminimaxChecklhs.sci79
-rw-r--r--macros/fminimaxCheckrhs.binbin0 -> 13076 bytes
-rw-r--r--macros/fminimaxCheckrhs.sci102
-rw-r--r--macros/fminimaxChecktype.binbin0 -> 9252 bytes
-rw-r--r--macros/fminimaxChecktype.sci65
-rw-r--r--macros/fminimaxCheckvector.binbin0 -> 9760 bytes
-rw-r--r--macros/fminimaxCheckvector.sci63
-rw-r--r--macros/fminunc.binbin0 -> 60820 bytes
-rw-r--r--macros/fminunc.sci427
-rw-r--r--macros/libbin528 -> 864 bytes
-rw-r--r--macros/linprog.binbin0 -> 28836 bytes
-rw-r--r--macros/linprog.sci199
-rw-r--r--macros/lsqlin.binbin58956 -> 59776 bytes
-rw-r--r--macros/lsqlin.sci5
-rw-r--r--macros/lsqnonneg.binbin29856 -> 30692 bytes
-rw-r--r--macros/lsqnonneg.sci6
-rw-r--r--macros/matrix_linprog.binbin0 -> 30556 bytes
-rwxr-xr-xmacros/matrix_linprog.sci245
-rw-r--r--macros/mps_linprog.binbin0 -> 9028 bytes
-rw-r--r--macros/mps_linprog.sci90
-rw-r--r--macros/names14
-rw-r--r--macros/qpipoptmat.binbin60708 -> 61536 bytes
-rw-r--r--macros/qpipoptmat.sci5
-rw-r--r--macros/symphonymat.binbin62364 -> 63268 bytes
-rw-r--r--macros/symphonymat.sci6
-rwxr-xr-xsci_gateway/cpp/LinCLP.hpp82
-rw-r--r--sci_gateway/cpp/builder_gateway_cpp.sce36
-rw-r--r--sci_gateway/cpp/libFAMOS.c10
-rwxr-xr-xsci_gateway/cpp/libFAMOS.sobin122920 -> 199006 bytes
-rw-r--r--sci_gateway/cpp/loader.sce5
-rw-r--r--sci_gateway/cpp/minbndNLP.hpp116
-rw-r--r--sci_gateway/cpp/minconNLP.hpp173
-rw-r--r--sci_gateway/cpp/minuncNLP.hpp113
-rw-r--r--sci_gateway/cpp/read_mps.cpp113
-rw-r--r--sci_gateway/cpp/sci_LinCLP.cpp119
-rw-r--r--sci_gateway/cpp/sci_LinProg.cpp150
-rw-r--r--sci_gateway/cpp/sci_iofunc.cpp67
-rw-r--r--sci_gateway/cpp/sci_iofunc.hpp16
-rw-r--r--sci_gateway/cpp/sci_ipoptfminbnd.cpp195
-rw-r--r--sci_gateway/cpp/sci_ipoptfmincon.cpp273
-rw-r--r--sci_gateway/cpp/sci_ipoptfminunc.cpp201
-rw-r--r--sci_gateway/cpp/sci_minbndNLP.cpp353
-rw-r--r--sci_gateway/cpp/sci_minconNLP.cpp797
-rw-r--r--sci_gateway/cpp/sci_minuncNLP.cpp377
93 files changed, 10011 insertions, 36 deletions
diff --git a/demos/exmip1.mps b/demos/exmip1.mps
new file mode 100644
index 0000000..4f73ac5
--- /dev/null
+++ b/demos/exmip1.mps
@@ -0,0 +1,70 @@
+************************************************************************
+*
+* The data in this file represents the following problem:
+*
+* Minimize or maximize Z = x1 + 2x5 - x8
+*
+* Subject to:
+*
+* 2.5 <= 3x1 + x2 - 2x4 - x5 - x8
+* 2x2 + 1.1x3 <= 2.1
+* x3 + x6 = 4.0
+* 1.8 <= 2.8x4 -1.2x7 <= 5.0
+* 3.0 <= 5.6x1 + x5 + 1.9x8 <= 15.0
+*
+* where:
+*
+* 2.5 <= x1
+* 0 <= x2 <= 4.1
+* 0 <= x3
+* 0 <= x4
+* 0.5 <= x5 <= 4.0
+* 0 <= x6
+* 0 <= x7
+* 0 <= x8 <= 4.3
+*
+* x3, x4 are 0,1 variables.
+*
+************************************************************************
+NAME EXAMPLE
+ROWS
+ N OBJ
+ G ROW01
+ L ROW02
+ E ROW03
+ G ROW04
+ L ROW05
+COLUMNS
+ COL01 OBJ 1.0
+ COL01 ROW01 3.0 ROW05 5.6
+ COL02 ROW01 1.0 ROW02 2.0
+*
+* Mark COL03 and COL04 as integer variables.
+*
+ INT1 'MARKER' 'INTORG'
+ COL03 ROW02 1.1 ROW03 1.0
+ COL04 ROW01 -2.0 ROW04 2.8
+ INT1END 'MARKER' 'INTEND'
+*
+ COL05 OBJ 2.0
+ COL05 ROW01 -1.0 ROW05 1.0
+ COL06 ROW03 1.0
+ COL07 ROW04 -1.2
+ COL08 OBJ -1.0
+ COL08 ROW01 -1.0 ROW05 1.9
+RHS
+ RHS1 ROW01 2.5
+ RHS1 ROW02 2.1
+ RHS1 ROW03 4.0
+ RHS1 ROW04 1.8
+ RHS1 ROW05 15.0
+RANGES
+ RNG1 ROW04 3.2
+ RNG1 ROW05 12.0
+BOUNDS
+ LO BND1 COL01 2.5
+ UP BND1 COL02 4.1
+ LO BND1 COL05 0.5
+ UP BND1 COL05 4.0
+ UP BND1 COL08 4.3
+ENDATA
diff --git a/demos/fgoalattain.dem.sce b/demos/fgoalattain.dem.sce
new file mode 100644
index 0000000..89a5957
--- /dev/null
+++ b/demos/fgoalattain.dem.sce
@@ -0,0 +1,26 @@
+mode(1)
+//
+// Demo of fgoalattain.sci
+//
+
+function f1 = fun(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
+f1(4)=-x(1)-x(2)
+f1(5)=x(1)+x(2)-8
+endfunction
+x0=[-1,1];
+halt() // Press return to continue
+
+goal=[-5,-3,-2,-1,-4];
+weight=abs(goal)
+//xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
+//fval = [4 3.99]
+halt() // Press return to continue
+
+//Run fgoalattain
+[xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,x0,goal,weight)
+halt() // Press return to continue
+
+//========= E N D === O F === D E M O =========//
diff --git a/demos/fminbnd.dem.sce b/demos/fminbnd.dem.sce
new file mode 100644
index 0000000..a9b4865
--- /dev/null
+++ b/demos/fminbnd.dem.sce
@@ -0,0 +1,54 @@
+mode(1)
+//
+// Demo of fminbnd.sci
+//
+
+//Find x in R^6 such that it minimizes:
+//f(x)= sin(x1) + sin(x2) + sin(x3) + sin(x4) + sin(x5) + sin(x6)
+//-2 <= x1,x2,x3,x4,x5,x6 <= 2
+//Objective function to be minimised
+function y=f(x)
+y=0
+for i =1:6
+y=y+sin(x(i));
+end
+endfunction
+//Variable bounds
+x1 = [-2, -2, -2, -2, -2, -2];
+x2 = [2, 2, 2, 2, 2, 2];
+//Options
+options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+//Calling Ipopt
+[x,fval] =fminbnd(f, x1, x2, options)
+halt() // Press return to continue
+
+//Find x in R such that it minimizes:
+//f(x)= 1/x^2
+//0 <= x <= 1000
+//Objective function to be minimised
+function y=f(x)
+y=1/x^2
+endfunction
+//Variable bounds
+x1 = [0];
+x2 = [1000];
+//Calling Ipopt
+[x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2)
+halt() // Press return to continue
+
+//The below problem is an unbounded problem:
+//Find x in R^2 such that it minimizes:
+//f(x)= -[(x1-1)^2 + (x2-1)^2]
+//-inf <= x1,x2 <= inf
+//Objective function to be minimised
+function y=f(x)
+y=-((x(1)-1)^2+(x(2)-1)^2);
+endfunction
+//Variable bounds
+x1 = [-%inf , -%inf];
+x2 = [];
+//Options
+options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+//Calling Ipopt
+[x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2, options)
+//========= E N D === O F === D E M O =========//
diff --git a/demos/fmincon.dem.sce b/demos/fmincon.dem.sce
new file mode 100644
index 0000000..790c67f
--- /dev/null
+++ b/demos/fmincon.dem.sce
@@ -0,0 +1,155 @@
+mode(1)
+//
+// Demo of fmincon.sci
+//
+
+//Find x in R^2 such that it minimizes:
+//f(x)= -x1 -x2/3
+//x0=[0,0]
+//constraint-1 (c1): x1 + x2 <= 2
+//constraint-2 (c2): x1 + x2/4 <= 1
+//constraint-3 (c3): x1 - x2 <= 2
+//constraint-4 (c4): -x1/4 - x2 <= 1
+//constraint-5 (c5): -x1 - x2 <= -1
+//constraint-6 (c6): -x1 + x2 <= 2
+//constraint-7 (c7): x1 + x2 = 2
+//Objective function to be minimised
+function y=f(x)
+y=-x(1)-x(2)/3;
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0 , 0];
+A=[1,1 ; 1,1/4 ; 1,-1 ; -1/4,-1 ; -1,-1 ; -1,1];
+b=[2;1;2;1;-1;2];
+Aeq=[1,1];
+beq=[2];
+lb=[];
+ub=[];
+nlc=[];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-1,-1/3];
+endfunction
+//Hessian of lagrangian
+function y= lHess(x,obj,lambda)
+y= obj*[0,0;0,0]
+endfunction
+//Options
+options=list("GradObj", fGrad, "Hessian", lHess);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+halt() // Press return to continue
+
+//Find x in R^3 such that it minimizes:
+//f(x)= x1*x2 + x2*x3
+//x0=[0.1 , 0.1 , 0.1]
+//constraint-1 (c1): x1^2 - x2^2 + x3^2 <= 2
+//constraint-2 (c2): x1^2 + x2^2 + x3^2 <= 10
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c = [x(1)^2 - x(2)^2 + x(3)^2 - 2 , x(1)^2 + x(2)^2 + x(3)^2 - 10];
+ceq = [];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,-2,0;0,0,2] + lambda(2)*[2,0,0;0,2,0;0,0,2]
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg=[2*x(1) , -2*x(2) , 2*x(3) ; 2*x(1) , 2*x(2) , 2*x(3)];
+ceqg=[];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[x,fval,exitflag,output] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+halt() // Press return to continue
+
+//The below problem is an unbounded problem:
+//Find x in R^3 such that it minimizes:
+//f(x)= -(x1^2 + x2^2 + x3^2)
+//x0=[0.1 , 0.1 , 0.1]
+// x1 <= 0
+// x2 <= 0
+// x3 <= 0
+//Objective function to be minimised
+function y=f(x)
+y=-(x(1)^2+x(2)^2+x(3)^2);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[0,0,0];
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500]);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,[],options)
+halt() // Press return to continue
+
+//The below problem is an infeasible problem:
+//Find x in R^3 such that in minimizes:
+//f(x)=x1*x2 + x2*x3
+//x0=[1,1,1]
+//constraint-1 (c1): x1^2 <= 1
+//constraint-2 (c2): x1^2 + x2^2 <= 1
+//constraint-3 (c3): x3^2 <= 1
+//constraint-4 (c4): x1^3 = 0.5
+//constraint-5 (c5): x2^2 + x3^2 = 0.75
+// 0 <= x1 <=0.6
+// 0.2 <= x2 <= inf
+// -inf <= x3 <= 1
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[1,1,1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[0 0.2,-%inf];
+ub=[0.6 %inf,1];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c=[x(1)^2-1,x(1)^2+x(2)^2-1,x(3)^2-1];
+ceq=[x(1)^3-0.5,x(2)^2+x(3)^2-0.75];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,0,0;0,0,0] + lambda(2)*[2,0,0;0,2,0;0,0,0] +lambda(3)*[0,0,0;0,0,0;0,0,2] + lambda(4)*[6*x(1 ),0,0;0,0,0;0,0,0] + lambda(5)*[0,0,0;0,2,0;0,0,2];
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//========= E N D === O F === D E M O =========//
diff --git a/demos/fminimax.dem.sce b/demos/fminimax.dem.sce
new file mode 100644
index 0000000..404af00
--- /dev/null
+++ b/demos/fminimax.dem.sce
@@ -0,0 +1,73 @@
+mode(1)
+//
+// Demo of fminimax.sci
+//
+
+// A basic case :
+// we provide only the objective function and the nonlinear constraint
+// function
+function f = myfun(x)
+f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304; //Objectives
+f(2)= -x(1)^2 - 3*x(2)^2;
+f(3)= x(1) + 3*x(2) -18;
+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]
+maxfopt = 0
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output,lambda] = fminimax(myfun, x0)
+// Press ENTER to continue
+halt() // Press return to continue
+
+// A case where we provide the gradient of the objective
+// functions and the Jacobian matrix of the constraints.
+// The objective function and its gradient
+function f = myfun(x)
+f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304;
+f(2)= -x(1)^2 - 3*x(2)^2;
+f(3)= x(1) + 3*x(2) -18;
+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)
+// Inequality constraints
+c = [1.5 + x(1)*x(2) - x(1) - x(2), -x(1)*x(2) - 10]
+// No nonlinear equality constraints
+ceq=[]
+endfunction
+// Defining gradient of confungrad
+function [DC,DCeq] = cgrad(x)
+// DC(:,i) = gradient of the i-th constraint
+// DC = [
+// Dc1/Dx1 Dc1/Dx2
+// Dc2/Dx1 Dc2/Dx2
+// ]
+DC= [
+x(2)-1, -x(2)
+x(1)-1, -x(1)
+]'
+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]
+maxfopt = 6.73443
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+//========= E N D === O F === D E M O =========//
diff --git a/demos/fminunc.dem.sce b/demos/fminunc.dem.sce
new file mode 100644
index 0000000..80eed72
--- /dev/null
+++ b/demos/fminunc.dem.sce
@@ -0,0 +1,61 @@
+mode(1)
+//
+// Demo of fminunc.sci
+//
+
+//Find x in R^2 such that it minimizes the Rosenbrock function
+//f = 100*(x2 - x1^2)^2 + (1-x1)^2
+//Objective function to be minimised
+function y= f(x)
+y= 100*(x(2) - x(1)^2)^2 + (1-x(1))^2;
+endfunction
+//Starting point
+x0=[-1,2];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-400*x(1)*x(2) + 400*x(1)^3 + 2*x(1)-2, 200*(x(2)-x(1)^2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [1200*x(1)^2- 400*x(2) + 2, -400*x(1);-400*x(1), 200 ];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+halt() // Press return to continue
+
+//Find x in R^2 such that the below function is minimum
+//f = x1^2 + x2^2
+//Objective function to be minimised
+function y= f(x)
+y= x(1)^2 + x(2)^2;
+endfunction
+//Starting point
+x0=[2,1];
+//Calling Ipopt
+[xopt,fopt]=fminunc(f,x0)
+halt() // Press return to continue
+
+//The below problem is an unbounded problem:
+//Find x in R^2 such that the below function is minimum
+//f = - x1^2 - x2^2
+//Objective function to be minimised
+function y= f(x)
+y= -x(1)^2 - x(2)^2;
+endfunction
+//Starting point
+x0=[2,1];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-2*x(1),-2*x(2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [-2,0;0,-2];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+//========= E N D === O F === D E M O =========//
diff --git a/demos/linprog.dem.sce b/demos/linprog.dem.sce
new file mode 100755
index 0000000..337a5dc
--- /dev/null
+++ b/demos/linprog.dem.sce
@@ -0,0 +1,64 @@
+mode(1)
+//
+// Demo of linprog.sci
+//
+
+//Optimal problems
+//Linear program, linear inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b)
+// Press ENTER to continue
+halt() // Press return to continue
+
+//Linear program with Linear Inequalities and Equalities`
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq)
+// Press ENTER to continue
+halt() // Press return to continue
+
+//Linear program with all constraint types
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
+// Press ENTER to continue
+halt() // Press return to continue
+
+//Primal Infeasible Problem
+c=[-1,-1,-1]'
+A=[1,2,-1]
+b=[-4]
+Aeq=[1,5,3;1,1,0]
+beq=[10,100]
+lb=[0,0,0]
+ub=[%inf,%inf,%inf]
+[xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+// Press ENTER to continue
+halt() // Press return to continue
+
+//Dual Infeasible Problem
+c=[3,5,-7]'
+A=[-1,-1,4;1,1,4]
+b=[-8,5]
+Aeq=[]
+beq=[]
+lb=[-%inf,-%inf,-%inf]
+ub=[%inf,%inf,%inf]
+[xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+// Press ENTER to continue
+halt() // Press return to continue
+
+filepath = get_absolute_file_path('linprog.dem.sce');
+filepath = filepath + "exmip1.mps"
+[xopt,fopt,exitflag,output,lambda] =linprog(filepath);
+//========= E N D === O F === D E M O =========//
diff --git a/help/en_US/fgoalattain.xml b/help/en_US/fgoalattain.xml
new file mode 100644
index 0000000..29a9923
--- /dev/null
+++ b/help/en_US/fgoalattain.xml
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from fgoalattain.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="fgoalattain" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>fgoalattain</refname>
+ <refpurpose>Solves a multiobjective goal attainment problem</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ x = fgoalattain(fun,x0,goal,weight)
+ x = fgoalattain(fun,x0,goal,weight,A,b)
+ x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq)
+ x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub)
+ x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon)
+ x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,options)
+ [x,fval] = fgoalattain(...)
+ [x,fval,attainfactor] = fgoalattain(...)
+ [x,fval,attainfactor,exitflag] = fgoalattain(...)
+ [x,fval,attainfactor,exitflag,output] = fgoalattain(...)
+ [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...)
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>fun:</term>
+ <listitem><para> a function that accepts a vector x and returns a vector F</para></listitem></varlistentry>
+ <varlistentry><term>x0:</term>
+ <listitem><para> a nx1 or 1xn matrix of double, where n is the number of variables.</para></listitem></varlistentry>
+ <varlistentry><term>A:</term>
+ <listitem><para> a nil x n matrix of double, where n is the number of variables and</para></listitem></varlistentry>
+ <varlistentry><term>b:</term>
+ <listitem><para> a nil x 1 matrix of double, where nil is the number of linear</para></listitem></varlistentry>
+ <varlistentry><term>Aeq:</term>
+ <listitem><para> a nel x n matrix of double, where n is the number of variables</para></listitem></varlistentry>
+ <varlistentry><term>beq:</term>
+ <listitem><para> a nel x 1 matrix of double, where nel is the number of linear</para></listitem></varlistentry>
+ <varlistentry><term>lb:</term>
+ <listitem><para> a nx1 or 1xn matrix of double, where n is the number of variables.</para></listitem></varlistentry>
+ <varlistentry><term>ub:</term>
+ <listitem><para> a nx1 or 1xn matrix of double, where n is the number of variables.</para></listitem></varlistentry>
+ <varlistentry><term>nonlcon:</term>
+ <listitem><para> a function, the nonlinear constraints</para></listitem></varlistentry>
+ <varlistentry><term>options :</term>
+ <listitem><para> a list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>x:</term>
+ <listitem><para> a nx1 matrix of double, the computed solution of the optimization problem</para></listitem></varlistentry>
+ <varlistentry><term>fval:</term>
+ <listitem><para> a vector of double, the value of functions at x</para></listitem></varlistentry>
+ <varlistentry><term>attainfactor:</term>
+ <listitem><para> The amount of over- or underachievement of the goals,γ at the solution.</para></listitem></varlistentry>
+ <varlistentry><term>exitflag:</term>
+ <listitem><para> a 1x1 matrix of floating point integers, the exit status</para></listitem></varlistentry>
+ <varlistentry><term>output:</term>
+ <listitem><para> a struct, the details of the optimization process</para></listitem></varlistentry>
+ <varlistentry><term>lambda:</term>
+ <listitem><para> a struct, the Lagrange multipliers at optimum</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+fgoalattain solves the goal attainment problem, which is one formulation for minimizing a multiobjective optimization problem.
+Finds the minimum of a problem specified by:
+Minimise Y such that
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+\mbox{min}_{x,\gamma} &amp; f(x)-weight \ast \gamma \leq goal \\
+\mbox{subject to} &amp; c(x) \leq 0 \\
+&amp; c_{eq}(x) = 0 \\
+&amp; Ax \leq b \\
+&amp; A_{eq} x = b_{eq} \\
+&amp; lb \leq x \leq ub
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+The solver makes use of fmincon to find the minimum.
+ </para>
+ <para>
+The fgoalattain finds out the maximum value of Y for the objectives evaluated at the starting point and
+adds that as another variable to the vector x
+This is passed to the fmincon function to get the optimised value of Y
+Hence, the algorithm used mainly is "ipopt" to obtain the optimum solution
+The relations between f(x), Y, weights and goals are added as additional non-linear inequality constraints
+ </para>
+ <para>
+The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type "list" and contains the following fields.
+<itemizedlist>
+<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "GradCon", ---);</listitem>
+<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+<listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+<listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 &amp; m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+</itemizedlist>
+ </para>
+ <para>
+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.
+ </para>
+ <para>
+If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ </para>
+ <para>
+Furthermore, we must enable the "GradObj" option with the statement :
+<programlisting>
+minimaxOptions = list("GradObj",fGrad);
+</programlisting>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function. Note that, fGrad should be mentioned in the form of N x n where n is the number of variables, N is the number of functions in objective function.
+ </para>
+ <para>
+The constraint function must have header :
+<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).
+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.
+ </para>
+ <para>
+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.
+ </para>
+ <para>
+If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ </para>
+ <para>
+Furthermore, we must enable the "GradCon" option with the statement :
+<programlisting>
+minimaxOptions = list("GradCon",confunGrad);
+</programlisting>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function.
+ </para>
+ <para>
+The constraint derivative function must have header :
+<programlisting>
+[dc,dceq] = confungrad(x)
+</programlisting>
+where dc is a nni x n matrix of doubles and dceq is a nne x n matrix of doubles.
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.Iterations: The number of iterations performed during the search</listitem>
+<listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+<listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+<listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+<listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+<listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+<listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+<listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+function f1 = fun(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
+f1(4)=-x(1)-x(2)
+f1(5)=x(1)+x(2)-8
+endfunction
+x0=[-1,1];
+
+goal=[-5,-3,-2,-1,-4];
+weight=abs(goal)
+//xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
+//fval = [4 3.99]
+
+//Run fgoalattain
+[xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,x0,goal,weight)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>Prajwala TM, Sheetal Shalini , 2015</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/fminbnd.xml b/help/en_US/fminbnd.xml
new file mode 100644
index 0000000..baf2f34
--- /dev/null
+++ b/help/en_US/fminbnd.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from fminbnd.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="fminbnd" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>fminbnd</refname>
+ <refpurpose>Solves a multi-variable optimization problem on a bounded interval</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ xopt = fminbnd(f,x1,x2)
+ xopt = fminbnd(f,x1,x2,options)
+ [xopt,fopt] = fminbnd(.....)
+ [xopt,fopt,exitflag]= fminbnd(.....)
+ [xopt,fopt,exitflag,output]=fminbnd(.....)
+ [xopt,fopt,exitflag,output,lambda]=fminbnd(.....)
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>f :</term>
+ <listitem><para> a function, representing the objective function of the problem</para></listitem></varlistentry>
+ <varlistentry><term>x1 :</term>
+ <listitem><para> a vector, containing the lower bound of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables, where n is number of Variables</para></listitem></varlistentry>
+ <varlistentry><term>x2 :</term>
+ <listitem><para> a vector, containing the upper bound of the variables of size (1 X n) or (n X 1) or (0 X 0) where 'n' is the number of Variables. If x2 is empty it means upper bound is +infinity</para></listitem></varlistentry>
+ <varlistentry><term>options :</term>
+ <listitem><para> a list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>xopt :</term>
+ <listitem><para> a vector of doubles, containing the the computed solution of the optimization problem.</para></listitem></varlistentry>
+ <varlistentry><term>fopt :</term>
+ <listitem><para> a scalar of double, containing the the function value at x.</para></listitem></varlistentry>
+ <varlistentry><term>exitflag :</term>
+ <listitem><para> a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>output :</term>
+ <listitem><para> a structure, containing the information about the optimization. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>lambda :</term>
+ <listitem><para> a structure, containing the Lagrange multipliers of lower bound and upper bound at the optimized point. See below for details.</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+Search the minimum of a multi-variable function on bounded interval specified by :
+Find the minimum of f(x) such that
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+&amp;\mbox{min}_{x}
+&amp; f(x)\\
+&amp; \text{subject to} &amp; x1 \ &lt; x \ &lt; x2 \\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+The routine calls Ipopt for solving the Bounded Optimization problem, Ipopt is a library written in C++.
+ </para>
+ <para>
+The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type "list" and contains the following fields.
+<itemizedlist>
+<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], TolX, [----]);</listitem>
+<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+<listitem>TolX : a Scalar, containing the Tolerance value that the solver should take.</listitem>
+<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600], TolX, [1e-4]);</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.Iterations: The number of iterations performed during the search</listitem>
+<listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+<listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+<listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R^6 such that it minimizes:
+//f(x)= sin(x1) + sin(x2) + sin(x3) + sin(x4) + sin(x5) + sin(x6)
+//-2 <= x1,x2,x3,x4,x5,x6 <= 2
+//Objective function to be minimised
+function y=f(x)
+y=0
+for i =1:6
+y=y+sin(x(i));
+end
+endfunction
+//Variable bounds
+x1 = [-2, -2, -2, -2, -2, -2];
+x2 = [2, 2, 2, 2, 2, 2];
+//Options
+options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+//Calling Ipopt
+[x,fval] =fminbnd(f, x1, x2, options)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R such that it minimizes:
+//f(x)= 1/x^2
+//0 <= x <= 1000
+//Objective function to be minimised
+function y=f(x)
+y=1/x^2
+endfunction
+//Variable bounds
+x1 = [0];
+x2 = [1000];
+//Calling Ipopt
+[x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//The below problem is an unbounded problem:
+//Find x in R^2 such that it minimizes:
+//f(x)= -[(x1-1)^2 + (x2-1)^2]
+//-inf <= x1,x2 <= inf
+//Objective function to be minimised
+function y=f(x)
+y=-((x(1)-1)^2+(x(2)-1)^2);
+endfunction
+//Variable bounds
+x1 = [-%inf , -%inf];
+x2 = [];
+//Options
+options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+//Calling Ipopt
+[x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2, options)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>R.Vidyadhar , Vignesh Kannan</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/fmincon.xml b/help/en_US/fmincon.xml
new file mode 100644
index 0000000..d8a7c4b
--- /dev/null
+++ b/help/en_US/fmincon.xml
@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from fmincon.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="fmincon" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>fmincon</refname>
+ <refpurpose>Solves a multi-variable constrainted optimization problem</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ xopt = fmincon(f,x0,A,b)
+ xopt = fmincon(f,x0,A,b,Aeq,beq)
+ xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub)
+ xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc)
+ xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ [xopt,fopt] = fmincon(.....)
+ [xopt,fopt,exitflag]= fmincon(.....)
+ [xopt,fopt,exitflag,output]= fmincon(.....)
+ [xopt,fopt,exitflag,output,lambda]=fmincon(.....)
+ [xopt,fopt,exitflag,output,lambda,gradient]=fmincon(.....)
+ [xopt,fopt,exitflag,output,lambda,gradient,hessian]=fmincon(.....)
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>f :</term>
+ <listitem><para> a function, representing the objective function of the problem</para></listitem></varlistentry>
+ <varlistentry><term>x0 :</term>
+ <listitem><para> a vector of doubles, containing the starting values of variables of size (1 X n) or (n X 1) where 'n' is the number of Variables</para></listitem></varlistentry>
+ <varlistentry><term>A :</term>
+ <listitem><para> a matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints</para></listitem></varlistentry>
+ <varlistentry><term>b :</term>
+ <listitem><para> a vector of doubles, related to 'A' and containing the the Right hand side equation of the linear inequality constraints of size (m X 1)</para></listitem></varlistentry>
+ <varlistentry><term>Aeq :</term>
+ <listitem><para> a matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where 'm1' is the number of linear equality constraints</para></listitem></varlistentry>
+ <varlistentry><term>beq :</term>
+ <listitem><para> a vector of doubles, related to 'Aeq' and containing the the Right hand side equation of the linear equality constraints of size (m1 X 1)</para></listitem></varlistentry>
+ <varlistentry><term>lb :</term>
+ <listitem><para> a vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables</para></listitem></varlistentry>
+ <varlistentry><term>ub :</term>
+ <listitem><para> a vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables</para></listitem></varlistentry>
+ <varlistentry><term>nlc :</term>
+ <listitem><para> a function, representing the Non-linear Constraints functions(both Equality and Inequality) of the problem. It is declared in such a way that non-linear inequality constraints are defined first as a single row vector (c), followed by non-linear equality constraints as another single row vector (ceq). Refer Example for definition of Constraint function.</para></listitem></varlistentry>
+ <varlistentry><term>options :</term>
+ <listitem><para> a list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>xopt :</term>
+ <listitem><para> a vector of doubles, cointating the computed solution of the optimization problem</para></listitem></varlistentry>
+ <varlistentry><term>fopt :</term>
+ <listitem><para> a scalar of double, containing the the function value at x</para></listitem></varlistentry>
+ <varlistentry><term>exitflag :</term>
+ <listitem><para> a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>output :</term>
+ <listitem><para> a structure, containing the information about the optimization. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>lambda :</term>
+ <listitem><para> a structure, containing the Lagrange multipliers of lower bound, upper bound and constraints at the optimized point. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>gradient :</term>
+ <listitem><para> a vector of doubles, containing the Objective's gradient of the solution.</para></listitem></varlistentry>
+ <varlistentry><term>hessian :</term>
+ <listitem><para> a matrix of doubles, containing the Lagrangian's hessian of the solution.</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+Search the minimum of a constrained optimization problem specified by :
+Find the minimum of f(x) such that
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+&amp;\mbox{min}_{x}
+&amp; f(x) \\
+&amp; \text{subject to} &amp; A*x \leq b \\
+&amp; &amp; Aeq*x \ = beq\\
+&amp; &amp; c(x) \leq 0\\
+&amp; &amp; ceq(x) \ = 0\\
+&amp; &amp; lb \leq x \leq ub \\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+The routine calls Ipopt for solving the Constrained Optimization problem, Ipopt is a library written in C++.
+ </para>
+ <para>
+The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type "list" and contains the following fields.
+<itemizedlist>
+<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "Hessian", ---, "GradCon", ---);</listitem>
+<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+<listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+<listitem>Hessian : a function, representing the hessian function of the Lagrange in Symmetric Matrix Form with Input parameters x, Objective factor and Lambda. Refer Example for definition of Lagrangian Hessian function.</listitem>
+<listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 &amp; m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.Iterations: The number of iterations performed during the search</listitem>
+<listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+<listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+<listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+<listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+<listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+<listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+<listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R^2 such that it minimizes:
+//f(x)= -x1 -x2/3
+//x0=[0,0]
+//constraint-1 (c1): x1 + x2 <= 2
+//constraint-2 (c2): x1 + x2/4 <= 1
+//constraint-3 (c3): x1 - x2 <= 2
+//constraint-4 (c4): -x1/4 - x2 <= 1
+//constraint-5 (c5): -x1 - x2 <= -1
+//constraint-6 (c6): -x1 + x2 <= 2
+//constraint-7 (c7): x1 + x2 = 2
+//Objective function to be minimised
+function y=f(x)
+y=-x(1)-x(2)/3;
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0 , 0];
+A=[1,1 ; 1,1/4 ; 1,-1 ; -1/4,-1 ; -1,-1 ; -1,1];
+b=[2;1;2;1;-1;2];
+Aeq=[1,1];
+beq=[2];
+lb=[];
+ub=[];
+nlc=[];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-1,-1/3];
+endfunction
+//Hessian of lagrangian
+function y= lHess(x,obj,lambda)
+y= obj*[0,0;0,0]
+endfunction
+//Options
+options=list("GradObj", fGrad, "Hessian", lHess);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R^3 such that it minimizes:
+//f(x)= x1*x2 + x2*x3
+//x0=[0.1 , 0.1 , 0.1]
+//constraint-1 (c1): x1^2 - x2^2 + x3^2 <= 2
+//constraint-2 (c2): x1^2 + x2^2 + x3^2 <= 10
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c = [x(1)^2 - x(2)^2 + x(3)^2 - 2 , x(1)^2 + x(2)^2 + x(3)^2 - 10];
+ceq = [];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,-2,0;0,0,2] + lambda(2)*[2,0,0;0,2,0;0,0,2]
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg=[2*x(1) , -2*x(2) , 2*x(3) ; 2*x(1) , 2*x(2) , 2*x(3)];
+ceqg=[];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[x,fval,exitflag,output] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//The below problem is an unbounded problem:
+//Find x in R^3 such that it minimizes:
+//f(x)= -(x1^2 + x2^2 + x3^2)
+//x0=[0.1 , 0.1 , 0.1]
+// x1 <= 0
+// x2 <= 0
+// x3 <= 0
+//Objective function to be minimised
+function y=f(x)
+y=-(x(1)^2+x(2)^2+x(3)^2);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[0,0,0];
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500]);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,[],options)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//The below problem is an infeasible problem:
+//Find x in R^3 such that in minimizes:
+//f(x)=x1*x2 + x2*x3
+//x0=[1,1,1]
+//constraint-1 (c1): x1^2 <= 1
+//constraint-2 (c2): x1^2 + x2^2 <= 1
+//constraint-3 (c3): x3^2 <= 1
+//constraint-4 (c4): x1^3 = 0.5
+//constraint-5 (c5): x2^2 + x3^2 = 0.75
+// 0 <= x1 <=0.6
+// 0.2 <= x2 <= inf
+// -inf <= x3 <= 1
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[1,1,1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[0 0.2,-%inf];
+ub=[0.6 %inf,1];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c=[x(1)^2-1,x(1)^2+x(2)^2-1,x(3)^2-1];
+ceq=[x(1)^3-0.5,x(2)^2+x(3)^2-0.75];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,0,0;0,0,0] + lambda(2)*[2,0,0;0,2,0;0,0,0] +lambda(3)*[0,0,0;0,0,0;0,0,2] + lambda(4)*[6*x(1 ),0,0;0,0,0;0,0,0] + lambda(5)*[0,0,0;0,2,0;0,0,2];
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>R.Vidyadhar , Vignesh Kannan</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/fminimax.xml b/help/en_US/fminimax.xml
new file mode 100644
index 0000000..ddab078
--- /dev/null
+++ b/help/en_US/fminimax.xml
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from fminimax.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="fminimax" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>fminimax</refname>
+ <refpurpose>Solves minimax constraint problem</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ x = fminimax(fun,x0)
+ x = fminimax(fun,x0,A,b)
+ x = fminimax(fun,x0,A,b,Aeq,beq)
+ x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub)
+ x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun)
+ x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun,options)
+ [x, fval] = fmincon(.....)
+ [x, fval, maxfval]= fmincon(.....)
+ [x, fval, maxfval, exitflag]= fmincon(.....)
+ [x, fval, maxfval, exitflag, output]= fmincon(.....)
+ [x, fval, maxfval, exitflag, output, lambda]= fmincon(.....)
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>fun:</term>
+ <listitem><para> The function to be minimized. fun is a function that accepts a vector x and returns a vector F, the objective functions evaluated at x.</para></listitem></varlistentry>
+ <varlistentry><term>x0:</term>
+ <listitem><para> a nx1 or 1xn matrix of doubles, where n is the number of variables, the initial guess for the optimization algorithm</para></listitem></varlistentry>
+ <varlistentry><term>A:</term>
+ <listitem><para> a nil x n matrix of doubles, where n is the number of variables and nil is the number of linear inequalities. If A==[] and b==[], it is assumed that there is no linear inequality constraints. If (A==[] &amp; b&lt;&gt;[]), fminimax generates an error (the same happens if (A&lt;&gt;[] &amp; b==[]))</para></listitem></varlistentry>
+ <varlistentry><term>b:</term>
+ <listitem><para> a nil x 1 matrix of doubles, where nil is the number of linear inequalities</para></listitem></varlistentry>
+ <varlistentry><term>Aeq:</term>
+ <listitem><para> a nel x n matrix of doubles, where n is the number of variables and nel is the number of linear equalities. If Aeq==[] and beq==[], it is assumed that there is no linear equality constraints. If (Aeq==[] &amp; beq&lt;&gt;[]), fminimax generates an error (the same happens if (Aeq&lt;&gt;[] &amp; beq==[]))</para></listitem></varlistentry>
+ <varlistentry><term>beq:</term>
+ <listitem><para> a nel x 1 matrix of doubles, where nel is the number of linear equalities</para></listitem></varlistentry>
+ <varlistentry><term>lb:</term>
+ <listitem><para> a nx1 or 1xn matrix of doubles, where n is the number of variables. The lower bound for x. If lb==[], then the lower bound is automatically set to -inf</para></listitem></varlistentry>
+ <varlistentry><term>ub:</term>
+ <listitem><para> a nx1 or 1xn matrix of doubles, where n is the number of variables. The upper bound for x. If ub==[], then the upper bound is automatically set to +inf</para></listitem></varlistentry>
+ <varlistentry><term>nonlinfun:</term>
+ <listitem><para> function that computes the nonlinear inequality constraints c(x) &lt;= 0 and nonlinear equality constraints ceq(x) = 0.</para></listitem></varlistentry>
+ <varlistentry><term>x:</term>
+ <listitem><para> a nx1 matrix of doubles, the computed solution of the optimization problem</para></listitem></varlistentry>
+ <varlistentry><term>fval:</term>
+ <listitem><para> a vector of doubles, the value of fun at x</para></listitem></varlistentry>
+ <varlistentry><term>maxfval:</term>
+ <listitem><para> a 1x1 matrix of doubles, the maximum value in vector fval</para></listitem></varlistentry>
+ <varlistentry><term>exitflag:</term>
+ <listitem><para> a 1x1 matrix of floating point integers, the exit status</para></listitem></varlistentry>
+ <varlistentry><term>output:</term>
+ <listitem><para> a struct, the details of the optimization process</para></listitem></varlistentry>
+ <varlistentry><term>lambda:</term>
+ <listitem><para> a struct, the Lagrange multipliers at optimum</para></listitem></varlistentry>
+ <varlistentry><term>options:</term>
+ <listitem><para> a list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+fminimax minimizes the worst-case (largest) value of a set of multivariable functions, starting at an initial estimate. This is generally referred to as the minimax problem.
+ </para>
+ <para>
+<latex>
+\min_{x} \max_{i} F_{i}(x)\: \textrm{such that} \:\begin{cases}
+&amp; c(x) \leq 0 \\
+&amp; ceq(x) = 0 \\
+&amp; A.x \leq b \\
+&amp; Aeq.x = beq \\
+&amp; minmaxLb \leq x \leq minmaxUb
+\end{cases}
+</latex>
+ </para>
+ <para>
+Currently, fminimax calls fmincon which uses the ip-opt algorithm.
+ </para>
+ <para>
+max-min problems can also be solved with fminimax, using the identity
+ </para>
+ <para>
+<latex>
+\max_{x} \min_{i} F_{i}(x) = -\min_{x} \max_{i} \left( -F_{i}(x) \right)
+</latex>
+ </para>
+ <para>
+The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type "list" and contains the following fields.
+<itemizedlist>
+<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "GradCon", ---);</listitem>
+<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+<listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+<listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 &amp; m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The objective function must have header :
+<programlisting>
+F = fun(x)
+</programlisting>
+where x is a n x 1 matrix of doubles and F is a m x 1 matrix of doubles where m is the total number of objective functions inside F.
+On input, the variable x contains the current point and, on output, the variable F must contain the objective function values.
+ </para>
+ <para>
+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.
+ </para>
+ <para>
+If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ </para>
+ <para>
+Furthermore, we must enable the "GradObj" option with the statement :
+<programlisting>
+minimaxOptions = list("GradObj",fGrad);
+</programlisting>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function. Note that, fGrad should be mentioned in the form of N x n where n is the number of variables, N is the number of functions in objective function.
+ </para>
+ <para>
+The constraint function must have header :
+<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).
+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.
+ </para>
+ <para>
+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.
+ </para>
+ <para>
+If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ </para>
+ <para>
+Furthermore, we must enable the "GradCon" option with the statement :
+<programlisting>
+minimaxOptions = list("GradCon",confunGrad);
+</programlisting>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function.
+ </para>
+ <para>
+The constraint derivative function must have header :
+<programlisting>
+[dc,dceq] = confungrad(x)
+</programlisting>
+where dc is a nni x n matrix of doubles and dceq is a nne x n matrix of doubles.
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.Iterations: The number of iterations performed during the search</listitem>
+<listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+<listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+<listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+<listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+<listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+<listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+<listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+// A basic case :
+// we provide only the objective function and the nonlinear constraint
+// function
+function f = myfun(x)
+f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304; //Objectives
+f(2)= -x(1)^2 - 3*x(2)^2;
+f(3)= x(1) + 3*x(2) -18;
+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]
+maxfopt = 0
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output,lambda] = fminimax(myfun, x0)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+// A case where we provide the gradient of the objective
+// functions and the Jacobian matrix of the constraints.
+// The objective function and its gradient
+function f = myfun(x)
+f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304;
+f(2)= -x(1)^2 - 3*x(2)^2;
+f(3)= x(1) + 3*x(2) -18;
+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)
+// Inequality constraints
+c = [1.5 + x(1)*x(2) - x(1) - x(2), -x(1)*x(2) - 10]
+// No nonlinear equality constraints
+ceq=[]
+endfunction
+// Defining gradient of confungrad
+function [DC,DCeq] = cgrad(x)
+// DC(:,i) = gradient of the i-th constraint
+// DC = [
+// Dc1/Dx1 Dc1/Dx2
+// Dc2/Dx1 Dc2/Dx2
+// ]
+DC= [
+x(2)-1, -x(2)
+x(1)-1, -x(1)
+]'
+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]
+maxfopt = 6.73443
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>Animesh Baranawal</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/fminunc.xml b/help/en_US/fminunc.xml
new file mode 100644
index 0000000..a28a82a
--- /dev/null
+++ b/help/en_US/fminunc.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from fminunc.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="fminunc" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>fminunc</refname>
+ <refpurpose>Solves a multi-variable unconstrainted optimization problem</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ xopt = fminunc(f,x0)
+ xopt = fminunc(f,x0,options)
+ [xopt,fopt] = fminunc(.....)
+ [xopt,fopt,exitflag]= fminunc(.....)
+ [xopt,fopt,exitflag,output]= fminunc(.....)
+ [xopt,fopt,exitflag,output,gradient]=fminunc(.....)
+ [xopt,fopt,exitflag,output,gradient,hessian]=fminunc(.....)
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>f :</term>
+ <listitem><para> a function, representing the objective function of the problem</para></listitem></varlistentry>
+ <varlistentry><term>x0 :</term>
+ <listitem><para> a vector of doubles, containing the starting of variables.</para></listitem></varlistentry>
+ <varlistentry><term>options:</term>
+ <listitem><para> a list, containing the option for user to specify. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>xopt :</term>
+ <listitem><para> a vector of doubles, the computed solution of the optimization problem.</para></listitem></varlistentry>
+ <varlistentry><term>fopt :</term>
+ <listitem><para> a scalar of double, the function value at x.</para></listitem></varlistentry>
+ <varlistentry><term>exitflag :</term>
+ <listitem><para> a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>output :</term>
+ <listitem><para> a structure, containing the information about the optimization. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>gradient :</term>
+ <listitem><para> a vector of doubles, containing the the gradient of the solution.</para></listitem></varlistentry>
+ <varlistentry><term>hessian :</term>
+ <listitem><para> a matrix of doubles, containing the the hessian of the solution.</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+Search the minimum of an unconstrained optimization problem specified by :
+Find the minimum of f(x) such that
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+&amp;\mbox{min}_{x}
+&amp; f(x)\\
+\end{eqnarray}
+</latex>
+ </para>
+ <para>
+The routine calls Ipopt for solving the Un-constrained Optimization problem, Ipopt is a library written in C++.
+ </para>
+ <para>
+The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type "list" and contains the following fields.
+<itemizedlist>
+<listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "Gradient", ---, "Hessian", ---);</listitem>
+<listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+<listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+<listitem>Gradient : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+<listitem>Hessian : a function, representing the hessian function of the Objective in Symmetric Matrix Form.</listitem>
+<listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+<listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+<listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.Iterations: The number of iterations performed during the search</listitem>
+<listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+<listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+<listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R^2 such that it minimizes the Rosenbrock function
+//f = 100*(x2 - x1^2)^2 + (1-x1)^2
+//Objective function to be minimised
+function y= f(x)
+y= 100*(x(2) - x(1)^2)^2 + (1-x(1))^2;
+endfunction
+//Starting point
+x0=[-1,2];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-400*x(1)*x(2) + 400*x(1)^3 + 2*x(1)-2, 200*(x(2)-x(1)^2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [1200*x(1)^2- 400*x(2) + 2, -400*x(1);-400*x(1), 200 ];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Find x in R^2 such that the below function is minimum
+//f = x1^2 + x2^2
+//Objective function to be minimised
+function y= f(x)
+y= x(1)^2 + x(2)^2;
+endfunction
+//Starting point
+x0=[2,1];
+//Calling Ipopt
+[xopt,fopt]=fminunc(f,x0)
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//The below problem is an unbounded problem:
+//Find x in R^2 such that the below function is minimum
+//f = - x1^2 - x2^2
+//Objective function to be minimised
+function y= f(x)
+y= -x(1)^2 - x(2)^2;
+endfunction
+//Starting point
+x0=[2,1];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-2*x(1),-2*x(2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [-2,0;0,-2];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>R.Vidyadhar , Vignesh Kannan</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/linprog.xml b/help/en_US/linprog.xml
new file mode 100755
index 0000000..1aa6e7c
--- /dev/null
+++ b/help/en_US/linprog.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * This help file was generated from linprog.sci using help_from_sci().
+ *
+ -->
+
+<refentry version="5.0-subset Scilab" xml:id="linprog" xml:lang="en"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:ns3="http://www.w3.org/1999/xhtml"
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:scilab="http://www.scilab.org"
+ xmlns:db="http://docbook.org/ns/docbook">
+
+ <refnamediv>
+ <refname>linprog</refname>
+ <refpurpose>Solves a linear programming problem.</refpurpose>
+ </refnamediv>
+
+
+<refsynopsisdiv>
+ <title>Calling Sequence</title>
+ <synopsis>
+ xopt = linprog(c,A,b)
+ xopt = linprog(c,A,b,Aeq,beq)
+ xopt = linprog(c,A,b,Aeq,beq,lb,ub)
+ xopt = linprog(c,A,b,Aeq,beq,lb,ub,param)
+ [xopt, fopt, exitflag, output, lambda] = linprog(file)
+ [xopt,fopt,exitflag,output,lambda] = linprog( ... )
+
+ </synopsis>
+</refsynopsisdiv>
+
+<refsection>
+ <title>Parameters</title>
+ <variablelist>
+ <varlistentry><term>c :</term>
+ <listitem><para> a vector of double, contains coefficients of the variables in the objective</para></listitem></varlistentry>
+ <varlistentry><term>A :</term>
+ <listitem><para> a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</para></listitem></varlistentry>
+ <varlistentry><term>b :</term>
+ <listitem><para> a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</para></listitem></varlistentry>
+ <varlistentry><term>Aeq :</term>
+ <listitem><para> a matrix of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.</para></listitem></varlistentry>
+ <varlistentry><term>beq :</term>
+ <listitem><para> a vector of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.</para></listitem></varlistentry>
+ <varlistentry><term>lb :</term>
+ <listitem><para> Lower bounds, specified as a vector or array of double. lb represents the lower bounds elementwise in lb ≤ x ≤ ub.</para></listitem></varlistentry>
+ <varlistentry><term>ub :</term>
+ <listitem><para> Upper bounds, specified as a vector or array of double. ub represents the upper bounds elementwise in lb ≤ x ≤ ub.</para></listitem></varlistentry>
+ <varlistentry><term>options :</term>
+ <listitem><para> a list containing the parameters to be set.</para></listitem></varlistentry>
+ <varlistentry><term>file :</term>
+ <listitem><para> a string describing the path to the mps file.</para></listitem></varlistentry>
+ <varlistentry><term>xopt :</term>
+ <listitem><para> a vector of double, the computed solution of the optimization problem.</para></listitem></varlistentry>
+ <varlistentry><term>fopt :</term>
+ <listitem><para> a double, the value of the function at x.</para></listitem></varlistentry>
+ <varlistentry><term>status :</term>
+ <listitem><para> status flag returned from symphony. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>output :</term>
+ <listitem><para> The output data structure contains detailed information about the optimization process. See below for details.</para></listitem></varlistentry>
+ <varlistentry><term>lambda :</term>
+ <listitem><para> The structure consist of the Lagrange multipliers at the solution of problem. See below for details.</para></listitem></varlistentry>
+ </variablelist>
+</refsection>
+
+<refsection>
+ <title>Description</title>
+ <para>
+OSI-CLP is used for solving the linear programming problems, OSI-CLP is a library written in C++.
+Search the minimum of a constrained linear programming problem specified by :
+ </para>
+ <para>
+<latex>
+\begin{eqnarray}
+&amp;\mbox{min}_{x}
+&amp; c^Tâ‹…x \\
+&amp; \text{subject to} &amp; Aâ‹…x \leq b \\
+&amp; &amp; Aeqâ‹…x = beq \\
+&amp; &amp; lb \leq x \leq ub \\
+\end{eqnarray}
+</latex>
+The routine calls Clp for solving the linear programming problem, Clp is a library written in C++.
+ </para>
+ <para>
+The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<itemizedlist>
+<listitem>exitflag=0 : Optimal Solution Found </listitem>
+<listitem>exitflag=1 : Primal Infeasible </listitem>
+<listitem>exitflag=2 : Dual Infeasible</listitem>
+<listitem>exitflag=3 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+<listitem>exitflag=4 : Solution Abandoned</listitem>
+<listitem>exitflag=5 : Primal objective limit reached.</listitem>
+<listitem>exitflag=6 : Dual objective limit reached.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ </para>
+ <para>
+The output data structure contains detailed informations about the optimization process.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>output.iterations: The number of iterations performed during the search</listitem>
+<listitem>output.constrviolation: The max-norm of the constraint violation.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type "struct" and contains the following fields.
+<itemizedlist>
+<listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+<listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+<listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+<listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+</itemizedlist>
+ </para>
+ <para>
+</para>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Optimal problems
+//Linear program, linear inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Linear program with Linear Inequalities and Equalities`
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Linear program with all constraint types
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Primal Infeasible Problem
+c=[-1,-1,-1]'
+A=[1,2,-1]
+b=[-4]
+Aeq=[1,5,3;1,1,0]
+beq=[10,100]
+lb=[0,0,0]
+ub=[%inf,%inf,%inf]
+[xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+//Dual Infeasible Problem
+c=[3,5,-7]'
+A=[-1,-1,4;1,1,4]
+b=[-8,5]
+Aeq=[]
+beq=[]
+lb=[-%inf,-%inf,-%inf]
+ub=[%inf,%inf,%inf]
+[xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+// Press ENTER to continue
+
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Examples</title>
+ <programlisting role="example"><![CDATA[
+filepath = get_absolute_file_path('linprog.dem.sce');
+filepath = filepath + "exmip1.mps"
+[xopt,fopt,exitflag,output,lambda] =linprog(filepath);
+ ]]></programlisting>
+</refsection>
+
+<refsection>
+ <title>Authors</title>
+ <simplelist type="vert">
+ <member>Bhanu Priya Sayal, Guru Pradeep Reddy</member>
+ </simplelist>
+</refsection>
+</refentry>
diff --git a/help/en_US/master_help.xml b/help/en_US/master_help.xml
index e59ac6c..0e162f7 100644
--- a/help/en_US/master_help.xml
+++ b/help/en_US/master_help.xml
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book [
<!--Begin Entities-->
+<!ENTITY a745e19a6383796e6f5680cdcc44cfcce SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/fgoalattain.xml">
+<!ENTITY a2b24cb19de46f878f11e6be9eb411170 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/fminbnd.xml">
+<!ENTITY a52664d077cac340a0384efe1ac107088 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/fmincon.xml">
+<!ENTITY a14f1077f437dbe35eb1cac51fed7a9fc SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/fminunc.xml">
+<!ENTITY aa809ed678033fc05c9b60a71de55b2ce SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/linprog.xml">
<!ENTITY a3d4ec65684b561d91f7a255acd23f51c SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/lsqlin.xml">
<!ENTITY aa4a031935f5eed6cfc8fc4a49823b00b SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/lsqnonneg.xml">
<!ENTITY a6b85f6e0c98751f20b68663a23cb4cd2 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipopt.xml">
@@ -81,6 +86,11 @@
<part xml:id='section_19f4f1e5726c01d683e8b82be0a7e910'>
<title>Symphony Toolbox</title>
+&a745e19a6383796e6f5680cdcc44cfcce;
+&a2b24cb19de46f878f11e6be9eb411170;
+&a52664d077cac340a0384efe1ac107088;
+&a14f1077f437dbe35eb1cac51fed7a9fc;
+&aa809ed678033fc05c9b60a71de55b2ce;
&a3d4ec65684b561d91f7a255acd23f51c;
&aa4a031935f5eed6cfc8fc4a49823b00b;
&a6b85f6e0c98751f20b68663a23cb4cd2;
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS
index 2a1feb2..5ece28b 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB
index 386e0dd..5ba83c4 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS
index 465e052..bfdb148 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS
index 629f1cc..c20654a 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA
index dab0526..0648b6b 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA
@@ -1,2 +1,2 @@
JavaSearch 1.0
-TMAP bs=2048 rt=1 fl=-1 id1=1279 id2=1
+TMAP bs=2048 rt=1 fl=-1 id1=1494 id2=1
diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP
index 775c132..af633ee 100644
--- a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP
+++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/_LaTeX_fgoalattain.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_fgoalattain.xml_1.png
new file mode 100644
index 0000000..7d7a4b6
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/_LaTeX_fgoalattain.xml_1.png
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/_LaTeX_fminbnd.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_fminbnd.xml_1.png
new file mode 100644
index 0000000..2634ce3
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/_LaTeX_fminbnd.xml_1.png
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/_LaTeX_fmincon.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_fmincon.xml_1.png
new file mode 100644
index 0000000..07910ed
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/_LaTeX_fmincon.xml_1.png
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/_LaTeX_fminunc.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_fminunc.xml_1.png
new file mode 100644
index 0000000..5250091
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/_LaTeX_fminunc.xml_1.png
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/_LaTeX_linprog.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_linprog.xml_1.png
new file mode 100644
index 0000000..1dd1d5e
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/_LaTeX_linprog.xml_1.png
Binary files differ
diff --git a/help/en_US/scilab_en_US_help/fgoalattain.html b/help/en_US/scilab_en_US_help/fgoalattain.html
new file mode 100644
index 0000000..a9aa43d
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/fgoalattain.html
@@ -0,0 +1,195 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>fgoalattain</title>
+ <style type="text/css" media="all">
+ @import url("scilab_code.css");
+ @import url("xml_code.css");
+ @import url("c_code.css");
+ @import url("style.css");
+ </style>
+ </head>
+ <body>
+ <div class="manualnavbar">
+ <table width="100%"><tr>
+ <td width="30%">
+ <span class="previous"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">&lt;&lt; Symphony Toolbox</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fminbnd.html">fminbnd &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+
+
+
+ <span class="path"><a href="index.html">Symphony Toolbox</a> &gt;&gt; <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> &gt; fgoalattain</span>
+
+ <br /><br />
+ <div class="refnamediv"><h1 class="refname">fgoalattain</h1>
+ <p class="refpurpose">Solves a multiobjective goal attainment problem</p></div>
+
+
+<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3>
+ <div class="synopsis"><pre><span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">)</span>
+<span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span>
+<span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span>
+<span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span>
+<span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">nonlcon</span><span class="default">)</span>
+<span class="default">x</span><span class="default"> = </span><span class="functionid">fgoalattain</span><span class="default">(</span><span class="default">fun</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">goal</span><span class="default">,</span><span class="default">weight</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">nonlcon</span><span class="default">,</span><span class="default">options</span><span class="default">)</span>
+<span class="default">[</span><span class="default">x</span><span class="default">,</span><span class="default">fval</span><span class="default">] = </span><span class="functionid">fgoalattain</span><span class="default">(...)</span>
+<span class="default">[</span><span class="default">x</span><span class="default">,</span><span class="default">fval</span><span class="default">,</span><span class="default">attainfactor</span><span class="default">] = </span><span class="functionid">fgoalattain</span><span class="default">(...)</span>
+<span class="default">[</span><span class="default">x</span><span class="default">,</span><span class="default">fval</span><span class="default">,</span><span class="default">attainfactor</span><span class="default">,</span><span class="default">exitflag</span><span class="default">] = </span><span class="functionid">fgoalattain</span><span class="default">(...)</span>
+<span class="default">[</span><span class="default">x</span><span class="default">,</span><span class="default">fval</span><span class="default">,</span><span class="default">attainfactor</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">] = </span><span class="functionid">fgoalattain</span><span class="default">(...)</span>
+<span class="default">[</span><span class="default">x</span><span class="default">,</span><span class="default">fval</span><span class="default">,</span><span class="default">attainfactor</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">] = </span><span class="functionid">fgoalattain</span><span class="default">(...)</span></pre></div></div>
+
+<div class="refsection"><h3 class="title">Parameters</h3>
+ <dl><dt><span class="term">fun:</span>
+ <dd><p class="para">a function that accepts a vector x and returns a vector F</p></dd></dt>
+ <dt><span class="term">x0:</span>
+ <dd><p class="para">a nx1 or 1xn matrix of double, where n is the number of variables.</p></dd></dt>
+ <dt><span class="term">A:</span>
+ <dd><p class="para">a nil x n matrix of double, where n is the number of variables and</p></dd></dt>
+ <dt><span class="term">b:</span>
+ <dd><p class="para">a nil x 1 matrix of double, where nil is the number of linear</p></dd></dt>
+ <dt><span class="term">Aeq:</span>
+ <dd><p class="para">a nel x n matrix of double, where n is the number of variables</p></dd></dt>
+ <dt><span class="term">beq:</span>
+ <dd><p class="para">a nel x 1 matrix of double, where nel is the number of linear</p></dd></dt>
+ <dt><span class="term">lb:</span>
+ <dd><p class="para">a nx1 or 1xn matrix of double, where n is the number of variables.</p></dd></dt>
+ <dt><span class="term">ub:</span>
+ <dd><p class="para">a nx1 or 1xn matrix of double, where n is the number of variables.</p></dd></dt>
+ <dt><span class="term">nonlcon:</span>
+ <dd><p class="para">a function, the nonlinear constraints</p></dd></dt>
+ <dt><span class="term">options :</span>
+ <dd><p class="para">a list, containing the option for user to specify. See below for details.</p></dd></dt>
+ <dt><span class="term">x:</span>
+ <dd><p class="para">a nx1 matrix of double, the computed solution of the optimization problem</p></dd></dt>
+ <dt><span class="term">fval:</span>
+ <dd><p class="para">a vector of double, the value of functions at x</p></dd></dt>
+ <dt><span class="term">attainfactor:</span>
+ <dd><p class="para">The amount of over- or underachievement of the goals,γ at the solution.</p></dd></dt>
+ <dt><span class="term">exitflag:</span>
+ <dd><p class="para">a 1x1 matrix of floating point integers, the exit status</p></dd></dt>
+ <dt><span class="term">output:</span>
+ <dd><p class="para">a struct, the details of the optimization process</p></dd></dt>
+ <dt><span class="term">lambda:</span>
+ <dd><p class="para">a struct, the Lagrange multipliers at optimum</p></dd></dt></dl></div>
+
+<div class="refsection"><h3 class="title">Description</h3>
+ <p class="para">fgoalattain solves the goal attainment problem, which is one formulation for minimizing a multiobjective optimization problem.
+Finds the minimum of a problem specified by:
+Minimise Y such that</p>
+ <p class="para"><span><img src='./_LaTeX_fgoalattain.xml_1.png' style='position:relative;top:64px;width:276px;height:136px'/></span></p>
+ <p class="para">The solver makes use of fmincon to find the minimum.</p>
+ <p class="para">The fgoalattain finds out the maximum value of Y for the objectives evaluated at the starting point and
+adds that as another variable to the vector x
+This is passed to the fmincon function to get the optimised value of Y
+Hence, the algorithm used mainly is &#0034;ipopt&#0034; to obtain the optimum solution
+The relations between f(x), Y, weights and goals are added as additional non-linear inequality constraints</p>
+ <p class="para">The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type &#0034;list&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>Syntax : options= list(&#0034;MaxIter&#0034;, [---], &#0034;CpuTime&#0034;, [---], &#0034;GradObj&#0034;, ---, &#0034;GradCon&#0034;, ---);</li>
+<li>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</li>
+<li>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</li>
+<li>GradObj : a function, representing the gradient function of the Objective in Vector Form.</li>
+<li>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 &amp; m3 are number of non-linear inequality and equality constraints respectively.</li>
+<li>Default Values : options = list(&#0034;MaxIter&#0034;, [3000], &#0034;CpuTime&#0034;, [600]);</li></ul></p>
+ <p class="para">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.</p>
+ <p class="para">If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.</p>
+ <p class="para">Furthermore, we must enable the &#0034;GradObj&#0034; option with the statement :
+<div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabid">minimaxOptions</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">GradObj</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabid">fGrad</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function. Note that, fGrad should be mentioned in the form of N x n where n is the number of variables, N is the number of functions in objective function.</p>
+ <p class="para">The constraint function must have header :
+<div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabopenclose">[</span><span class="scilabid">c</span><span class="scilabdefault">,</span> <span class="scilabid">ceq</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">confun</span><span class="scilabopenclose">(</span><span class="scilabid">x</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div>
+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).
+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.</p>
+ <p class="para">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.</p>
+ <p class="para">If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.</p>
+ <p class="para">Furthermore, we must enable the &#0034;GradCon&#0034; option with the statement :
+<div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabid">minimaxOptions</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">GradCon</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabid">confunGrad</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div>
+This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function.</p>
+ <p class="para">The constraint derivative function must have header :
+<div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabopenclose">[</span><span class="scilabid">dc</span><span class="scilabdefault">,</span><span class="scilabid">dceq</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">confungrad</span><span class="scilabopenclose">(</span><span class="scilabid">x</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div>
+where dc is a nni x n matrix of doubles and dceq is a nne x n matrix of doubles.</p>
+ <p class="para">The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<ul class="itemizedlist"><li>exitflag=0 : Optimal Solution Found</li>
+<li>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</li>
+<li>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</li>
+<li>exitflag=3 : Stop at Tiny Step.</li>
+<li>exitflag=4 : Solved To Acceptable Level.</li>
+<li>exitflag=5 : Converged to a point of local infeasibility.</li></ul></p>
+ <p class="para">For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/</p>
+ <p class="para">The output data structure contains detailed informations about the optimization process.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>output.Iterations: The number of iterations performed during the search</li>
+<li>output.Cpu_Time: The total cpu-time spend during the search</li>
+<li>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</li>
+<li>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</li></ul></p>
+ <p class="para">The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>lambda.lower: The Lagrange multipliers for the lower bound constraints.</li>
+<li>lambda.upper: The Lagrange multipliers for the upper bound constraints.</li>
+<li>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</li>
+<li>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</li>
+<li>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</li>
+<li>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</li></ul></p>
+ <p class="para"></p></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">f1</span><span class="scilaboperator">=</span><span class="scilabfunctionid">gattainObjfun</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">f1</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">=</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">48</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">40</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabnumber">304</span>
+<span class="scilabinputoutputargs">f1</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">=</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">3</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">f1</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">=</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabnumber">3</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">18</span>
+<span class="scilabinputoutputargs">f1</span><span class="scilabopenclose">(</span><span class="scilabnumber">4</span><span class="scilabopenclose">)</span><span class="scilaboperator">=</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">f1</span><span class="scilabopenclose">(</span><span class="scilabnumber">5</span><span class="scilabopenclose">)</span><span class="scilaboperator">=</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">8</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+
+<span class="scilabid">goal</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">weight</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://abs">abs</a><span class="scilabopenclose">(</span><span class="scilabid">goal</span><span class="scilabopenclose">)</span>
+<span class="scilabid">gval</span> <span class="scilaboperator">=</span>
+<span class="scilabopenclose">[</span><span class="scilaboperator">-</span> <span class="scilabnumber">0.0000011</span>
+<span class="scilaboperator">-</span> <span class="scilabnumber">63.999998</span>
+<span class="scilaboperator">-</span> <span class="scilabnumber">2.0000002</span>
+<span class="scilaboperator">-</span> <span class="scilabnumber">8.</span>
+<span class="scilabnumber">3.485D-08</span><span class="scilabopenclose">]</span>
+<span class="scilabid">z</span> <span class="scilaboperator">=</span>
+<span class="scilabopenclose">[</span><span class="scilabnumber">4.</span> <span class="scilabnumber">3.99</span><span class="scilabopenclose">]</span>
+
+<span class="scilabid">Run</span> <span class="scilabid">fgoalattain</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">attainfactor</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">fgoalattain</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">gattainObjfun</span><span class="scilabdefault">,</span><span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">goal</span><span class="scilabdefault">,</span><span class="scilabid">weight</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Authors</h3>
+ <ul class="itemizedlist"><li class="member">Prajwala TM, Sheetal Shalini , 2015</li></ul></div>
+ <br />
+
+ <div class="manualnavbar">
+ <table width="100%">
+ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
+<tr>
+ <td width="30%">
+ <span class="previous"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">&lt;&lt; Symphony Toolbox</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fminbnd.html">fminbnd &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+ </body>
+</html>
diff --git a/help/en_US/scilab_en_US_help/fminbnd.html b/help/en_US/scilab_en_US_help/fminbnd.html
new file mode 100644
index 0000000..9b64d03
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/fminbnd.html
@@ -0,0 +1,174 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>fminbnd</title>
+ <style type="text/css" media="all">
+ @import url("scilab_code.css");
+ @import url("xml_code.css");
+ @import url("c_code.css");
+ @import url("style.css");
+ </style>
+ </head>
+ <body>
+ <div class="manualnavbar">
+ <table width="100%"><tr>
+ <td width="30%">
+ <span class="previous"><a href="fgoalattain.html">&lt;&lt; fgoalattain</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fmincon.html">fmincon &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+
+
+
+ <span class="path"><a href="index.html">Symphony Toolbox</a> &gt;&gt; <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> &gt; fminbnd</span>
+
+ <br /><br />
+ <div class="refnamediv"><h1 class="refname">fminbnd</h1>
+ <p class="refpurpose">Solves a multi-variable optimization problem on a bounded interval</p></div>
+
+
+<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3>
+ <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">fminbnd</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x1</span><span class="default">,</span><span class="default">x2</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fminbnd</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x1</span><span class="default">,</span><span class="default">x2</span><span class="default">,</span><span class="default">options</span><span class="default">)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">] = </span><span class="functionid">fminbnd</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">]= </span><span class="functionid">fminbnd</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">]=</span><span class="functionid">fminbnd</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">]=</span><span class="functionid">fminbnd</span><span class="default">(.....)</span></pre></div></div>
+
+<div class="refsection"><h3 class="title">Parameters</h3>
+ <dl><dt><span class="term">f :</span>
+ <dd><p class="para">a function, representing the objective function of the problem</p></dd></dt>
+ <dt><span class="term">x1 :</span>
+ <dd><p class="para">a vector, containing the lower bound of the variables of size (1 X n) or (n X 1) where &#0039;n&#0039; is the number of Variables, where n is number of Variables</p></dd></dt>
+ <dt><span class="term">x2 :</span>
+ <dd><p class="para">a vector, containing the upper bound of the variables of size (1 X n) or (n X 1) or (0 X 0) where &#0039;n&#0039; is the number of Variables. If x2 is empty it means upper bound is +infinity</p></dd></dt>
+ <dt><span class="term">options :</span>
+ <dd><p class="para">a list, containing the option for user to specify. See below for details.</p></dd></dt>
+ <dt><span class="term">xopt :</span>
+ <dd><p class="para">a vector of doubles, containing the the computed solution of the optimization problem.</p></dd></dt>
+ <dt><span class="term">fopt :</span>
+ <dd><p class="para">a scalar of double, containing the the function value at x.</p></dd></dt>
+ <dt><span class="term">exitflag :</span>
+ <dd><p class="para">a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</p></dd></dt>
+ <dt><span class="term">output :</span>
+ <dd><p class="para">a structure, containing the information about the optimization. See below for details.</p></dd></dt>
+ <dt><span class="term">lambda :</span>
+ <dd><p class="para">a structure, containing the Lagrange multipliers of lower bound and upper bound at the optimized point. See below for details.</p></dd></dt></dl></div>
+
+<div class="refsection"><h3 class="title">Description</h3>
+ <p class="para">Search the minimum of a multi-variable function on bounded interval specified by :
+Find the minimum of f(x) such that</p>
+ <p class="para"><span><img src='./_LaTeX_fminbnd.xml_1.png' style='position:relative;top:20px;width:219px;height:48px'/></span></p>
+ <p class="para">The routine calls Ipopt for solving the Bounded Optimization problem, Ipopt is a library written in C++.</p>
+ <p class="para">The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type &#0034;list&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>Syntax : options= list(&#0034;MaxIter&#0034;, [---], &#0034;CpuTime&#0034;, [---], TolX, [----]);</li>
+<li>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</li>
+<li>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</li>
+<li>TolX : a Scalar, containing the Tolerance value that the solver should take.</li>
+<li>Default Values : options = list(&#0034;MaxIter&#0034;, [3000], &#0034;CpuTime&#0034;, [600], TolX, [1e-4]);</li></ul></p>
+ <p class="para">The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<ul class="itemizedlist"><li>exitflag=0 : Optimal Solution Found</li>
+<li>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</li>
+<li>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</li>
+<li>exitflag=3 : Stop at Tiny Step.</li>
+<li>exitflag=4 : Solved To Acceptable Level.</li>
+<li>exitflag=5 : Converged to a point of local infeasibility.</li></ul></p>
+ <p class="para">For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/</p>
+ <p class="para">The output data structure contains detailed informations about the optimization process.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>output.Iterations: The number of iterations performed during the search</li>
+<li>output.Cpu_Time: The total cpu-time spend during the search</li>
+<li>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</li>
+<li>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</li></ul></p>
+ <p class="para">The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>lambda.lower: The Lagrange multipliers for the lower bound constraints.</li>
+<li>lambda.upper: The Lagrange multipliers for the upper bound constraints.</li></ul></p>
+ <p class="para"></p></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^6 such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= sin(x1) + sin(x2) + sin(x3) + sin(x4) + sin(x5) + sin(x6)</span>
+<span class="scilabcomment">//-2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x1,x2,x3,x4,x5,x6 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 2</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabnumber">0</span>
+<span class="scilabskeyword">for</span> <span class="scilabid">i</span> <span class="scilaboperator">=</span><span class="scilabnumber">1</span><span class="scilabspecial">:</span><span class="scilabnumber">6</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabinputoutputargs">y</span><span class="scilaboperator">+</span><a class="scilabcommand" href="scilab://sin">sin</a><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabid">i</span><span class="scilabopenclose">)</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabskeyword">end</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Variable bounds</span>
+<span class="scilabid">x1</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">x2</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">100</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">TolX</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabnumber">1e-6</span><span class="scilabopenclose">]</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fminbnd</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x1</span><span class="scilabdefault">,</span> <span class="scilabid">x2</span><span class="scilabdefault">,</span> <span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= 1/x^2</span>
+<span class="scilabcomment">//0 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1000</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabinputoutputargs">x</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Variable bounds</span>
+<span class="scilabid">x1</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">x2</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fminbnd</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x1</span><span class="scilabdefault">,</span> <span class="scilabid">x2</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//The below problem is an unbounded problem:</span>
+<span class="scilabcomment">//Find x in R^2 such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= -[(x1-1)^2 + (x2-1)^2]</span>
+<span class="scilabcomment">//-inf </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x1,x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= inf</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilaboperator">-</span><span class="scilabopenclose">(</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">+</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Variable bounds</span>
+<span class="scilabid">x1</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span> <span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">x2</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">100</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">TolX</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabnumber">1e-6</span><span class="scilabopenclose">]</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fminbnd</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x1</span><span class="scilabdefault">,</span> <span class="scilabid">x2</span><span class="scilabdefault">,</span> <span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Authors</h3>
+ <ul class="itemizedlist"><li class="member">R.Vidyadhar , Vignesh Kannan</li></ul></div>
+ <br />
+
+ <div class="manualnavbar">
+ <table width="100%">
+ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
+<tr>
+ <td width="30%">
+ <span class="previous"><a href="fgoalattain.html">&lt;&lt; fgoalattain</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fmincon.html">fmincon &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+ </body>
+</html>
diff --git a/help/en_US/scilab_en_US_help/fmincon.html b/help/en_US/scilab_en_US_help/fmincon.html
new file mode 100644
index 0000000..242c58b
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/fmincon.html
@@ -0,0 +1,302 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>fmincon</title>
+ <style type="text/css" media="all">
+ @import url("scilab_code.css");
+ @import url("xml_code.css");
+ @import url("c_code.css");
+ @import url("style.css");
+ </style>
+ </head>
+ <body>
+ <div class="manualnavbar">
+ <table width="100%"><tr>
+ <td width="30%">
+ <span class="previous"><a href="fminbnd.html">&lt;&lt; fminbnd</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fminunc.html">fminunc &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+
+
+
+ <span class="path"><a href="index.html">Symphony Toolbox</a> &gt;&gt; <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> &gt; fmincon</span>
+
+ <br /><br />
+ <div class="refnamediv"><h1 class="refname">fmincon</h1>
+ <p class="refpurpose">Solves a multi-variable constrainted optimization problem</p></div>
+
+
+<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3>
+ <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">fmincon</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fmincon</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fmincon</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fmincon</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">nlc</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fmincon</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">nlc</span><span class="default">,</span><span class="default">options</span><span class="default">)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">] = </span><span class="functionid">fmincon</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">]= </span><span class="functionid">fmincon</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">]= </span><span class="functionid">fmincon</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">]=</span><span class="functionid">fmincon</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">,</span><span class="default">gradient</span><span class="default">]=</span><span class="functionid">fmincon</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">,</span><span class="default">gradient</span><span class="default">,</span><span class="default">hessian</span><span class="default">]=</span><span class="functionid">fmincon</span><span class="default">(.....)</span></pre></div></div>
+
+<div class="refsection"><h3 class="title">Parameters</h3>
+ <dl><dt><span class="term">f :</span>
+ <dd><p class="para">a function, representing the objective function of the problem</p></dd></dt>
+ <dt><span class="term">x0 :</span>
+ <dd><p class="para">a vector of doubles, containing the starting values of variables of size (1 X n) or (n X 1) where &#0039;n&#0039; is the number of Variables</p></dd></dt>
+ <dt><span class="term">A :</span>
+ <dd><p class="para">a matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where &#0039;m&#0039; is the number of linear inequality constraints</p></dd></dt>
+ <dt><span class="term">b :</span>
+ <dd><p class="para">a vector of doubles, related to &#0039;A&#0039; and containing the the Right hand side equation of the linear inequality constraints of size (m X 1)</p></dd></dt>
+ <dt><span class="term">Aeq :</span>
+ <dd><p class="para">a matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where &#0039;m1&#0039; is the number of linear equality constraints</p></dd></dt>
+ <dt><span class="term">beq :</span>
+ <dd><p class="para">a vector of doubles, related to &#0039;Aeq&#0039; and containing the the Right hand side equation of the linear equality constraints of size (m1 X 1)</p></dd></dt>
+ <dt><span class="term">lb :</span>
+ <dd><p class="para">a vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where &#0039;n&#0039; is the number of Variables</p></dd></dt>
+ <dt><span class="term">ub :</span>
+ <dd><p class="para">a vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where &#0039;n&#0039; is the number of Variables</p></dd></dt>
+ <dt><span class="term">nlc :</span>
+ <dd><p class="para">a function, representing the Non-linear Constraints functions(both Equality and Inequality) of the problem. It is declared in such a way that non-linear inequality constraints are defined first as a single row vector (c), followed by non-linear equality constraints as another single row vector (ceq). Refer Example for definition of Constraint function.</p></dd></dt>
+ <dt><span class="term">options :</span>
+ <dd><p class="para">a list, containing the option for user to specify. See below for details.</p></dd></dt>
+ <dt><span class="term">xopt :</span>
+ <dd><p class="para">a vector of doubles, cointating the computed solution of the optimization problem</p></dd></dt>
+ <dt><span class="term">fopt :</span>
+ <dd><p class="para">a scalar of double, containing the the function value at x</p></dd></dt>
+ <dt><span class="term">exitflag :</span>
+ <dd><p class="para">a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</p></dd></dt>
+ <dt><span class="term">output :</span>
+ <dd><p class="para">a structure, containing the information about the optimization. See below for details.</p></dd></dt>
+ <dt><span class="term">lambda :</span>
+ <dd><p class="para">a structure, containing the Lagrange multipliers of lower bound, upper bound and constraints at the optimized point. See below for details.</p></dd></dt>
+ <dt><span class="term">gradient :</span>
+ <dd><p class="para">a vector of doubles, containing the Objective&#0039;s gradient of the solution.</p></dd></dt>
+ <dt><span class="term">hessian :</span>
+ <dd><p class="para">a matrix of doubles, containing the Lagrangian&#0039;s hessian of the solution.</p></dd></dt></dl></div>
+
+<div class="refsection"><h3 class="title">Description</h3>
+ <p class="para">Search the minimum of a constrained optimization problem specified by :
+Find the minimum of f(x) such that</p>
+ <p class="para"><span><img src='./_LaTeX_fmincon.xml_1.png' style='position:relative;top:63px;width:221px;height:134px'/></span></p>
+ <p class="para">The routine calls Ipopt for solving the Constrained Optimization problem, Ipopt is a library written in C++.</p>
+ <p class="para">The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type &#0034;list&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>Syntax : options= list(&#0034;MaxIter&#0034;, [---], &#0034;CpuTime&#0034;, [---], &#0034;GradObj&#0034;, ---, &#0034;Hessian&#0034;, ---, &#0034;GradCon&#0034;, ---);</li>
+<li>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</li>
+<li>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</li>
+<li>GradObj : a function, representing the gradient function of the Objective in Vector Form.</li>
+<li>Hessian : a function, representing the hessian function of the Lagrange in Symmetric Matrix Form with Input parameters x, Objective factor and Lambda. Refer Example for definition of Lagrangian Hessian function.</li>
+<li>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 &amp; m3 are number of non-linear inequality and equality constraints respectively.</li>
+<li>Default Values : options = list(&#0034;MaxIter&#0034;, [3000], &#0034;CpuTime&#0034;, [600]);</li></ul></p>
+ <p class="para">The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<ul class="itemizedlist"><li>exitflag=0 : Optimal Solution Found</li>
+<li>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</li>
+<li>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</li>
+<li>exitflag=3 : Stop at Tiny Step.</li>
+<li>exitflag=4 : Solved To Acceptable Level.</li>
+<li>exitflag=5 : Converged to a point of local infeasibility.</li></ul></p>
+ <p class="para">For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/</p>
+ <p class="para">The output data structure contains detailed informations about the optimization process.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>output.Iterations: The number of iterations performed during the search</li>
+<li>output.Cpu_Time: The total cpu-time spend during the search</li>
+<li>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</li>
+<li>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</li></ul></p>
+ <p class="para">The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>lambda.lower: The Lagrange multipliers for the lower bound constraints.</li>
+<li>lambda.upper: The Lagrange multipliers for the upper bound constraints.</li>
+<li>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</li>
+<li>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</li>
+<li>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</li>
+<li>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</li></ul></p>
+ <p class="para"></p></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^2 such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= -x1 -x2/3</span>
+<span class="scilabcomment">//x0=[0,0]</span>
+<span class="scilabcomment">//constraint-1 (c1): x1 + x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 2</span>
+<span class="scilabcomment">//constraint-2 (c2): x1 + x2/4 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//constraint-3 (c3): x1 - x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 2</span>
+<span class="scilabcomment">//constraint-4 (c4): -x1/4 - x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//constraint-5 (c5): -x1 - x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= -1</span>
+<span class="scilabcomment">//constraint-6 (c6): -x1 + x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 2</span>
+<span class="scilabcomment">//constraint-7 (c7): x1 + x2 = 2</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">/</span><span class="scilabnumber">3</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point, linear constraints and variable bounds</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span> <span class="scilabdefault">,</span> <span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span> <span class="scilabdefault">;</span> <span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span> <span class="scilabdefault">;</span> <span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">nlc</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Gradient of objective function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Hessian of lagrangian</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">lHess</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">obj</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabinputoutputargs">obj</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">GradObj</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fGrad</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Hessian</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">lHess</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabdefault">,</span><span class="scilabid">grad</span><span class="scilabdefault">,</span><span class="scilabid">hessian</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fmincon</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">nlc</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^3 such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= x1*x2 + x2*x3</span>
+<span class="scilabcomment">//x0=[0.1 , 0.1 , 0.1]</span>
+<span class="scilabcomment">//constraint-1 (c1): x1^2 - x2^2 + x3^2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 2</span>
+<span class="scilabcomment">//constraint-2 (c2): x1^2 + x2^2 + x3^2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 10</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point, linear constraints and variable bounds</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0.1</span> <span class="scilabdefault">,</span> <span class="scilabnumber">0.1</span> <span class="scilabdefault">,</span> <span class="scilabnumber">0.1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Nonlinear constraints</span>
+<span class="scilabfkeyword">function</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">c</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">ceq</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabfunctionid">nlc</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">c</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">-</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">-</span> <span class="scilabnumber">2</span> <span class="scilabdefault">,</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">-</span> <span class="scilabnumber">10</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabinputoutputargs">ceq</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Gradient of objective function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Hessian of the Lagrange Function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">lHess</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">obj</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabinputoutputargs">obj</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Gradient of Non-Linear Constraints</span>
+<span class="scilabfkeyword">function</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">cg</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">ceqg</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabfunctionid">cGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">cg</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span> <span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> <span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span> <span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span> <span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> <span class="scilabdefault">,</span> <span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabinputoutputargs">ceqg</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">GradObj</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fGrad</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Hessian</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">lHess</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">GradCon</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">cGrad</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fmincon</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabfunctionid">nlc</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//The below problem is an unbounded problem:</span>
+<span class="scilabcomment">//Find x in R^3 such that it minimizes:</span>
+<span class="scilabcomment">//f(x)= -(x1^2 + x2^2 + x3^2)</span>
+<span class="scilabcomment">//x0=[0.1 , 0.1 , 0.1]</span>
+<span class="scilabcomment">// x1 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 0</span>
+<span class="scilabcomment">// x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 0</span>
+<span class="scilabcomment">// x3 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 0</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilaboperator">-</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point, linear constraints and variable bounds</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0.1</span> <span class="scilabdefault">,</span> <span class="scilabnumber">0.1</span> <span class="scilabdefault">,</span> <span class="scilabnumber">0.1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">500</span><span class="scilabopenclose">]</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabdefault">,</span><span class="scilabid">grad</span><span class="scilabdefault">,</span><span class="scilabid">hessian</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fmincon</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//The below problem is an infeasible problem:</span>
+<span class="scilabcomment">//Find x in R^3 such that in minimizes:</span>
+<span class="scilabcomment">//f(x)=x1*x2 + x2*x3</span>
+<span class="scilabcomment">//x0=[1,1,1]</span>
+<span class="scilabcomment">//constraint-1 (c1): x1^2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//constraint-2 (c2): x1^2 + x2^2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//constraint-3 (c3): x3^2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//constraint-4 (c4): x1^3 = 0.5</span>
+<span class="scilabcomment">//constraint-5 (c5): x2^2 + x3^2 = 0.75</span>
+<span class="scilabcomment">// 0 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x1 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">=0.6</span>
+<span class="scilabcomment">// 0.2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x2 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= inf</span>
+<span class="scilabcomment">// -inf </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= x3 </span><span class="scilabcomment">&#0060;</span><span class="scilabcomment">= 1</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point, linear constraints and variable bounds</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span> <span class="scilabnumber">0.2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0.6</span> <span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Nonlinear constraints</span>
+<span class="scilabfkeyword">function</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">c</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">ceq</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabfunctionid">nlc</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabinputoutputargs">ceq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">3</span><span class="scilaboperator">-</span><span class="scilabnumber">0.5</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">-</span><span class="scilabnumber">0.75</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Gradient of objective function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">+</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Hessian of the Lagrange Function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">lHess</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">obj</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabinputoutputargs">obj</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span><span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">4</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">6</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span> <span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">lambda</span><span class="scilabopenclose">(</span><span class="scilabnumber">5</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Gradient of Non-Linear Constraints</span>
+<span class="scilabfkeyword">function</span> <span class="scilabopenclose">[</span><span class="scilabinputoutputargs">cg</span><span class="scilabdefault">, </span><span class="scilabinputoutputargs">ceqg</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabfunctionid">cGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">cg</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabinputoutputargs">ceqg</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">3</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">3</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">GradObj</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fGrad</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Hessian</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">lHess</span><span class="scilabdefault">,</span><span class="scilabstring">&#0034;</span><span class="scilabstring">GradCon</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">cGrad</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">fval</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabdefault">,</span><span class="scilabid">grad</span><span class="scilabdefault">,</span><span class="scilabid">hessian</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">fmincon</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span> <span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabfunctionid">nlc</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Authors</h3>
+ <ul class="itemizedlist"><li class="member">R.Vidyadhar , Vignesh Kannan</li></ul></div>
+ <br />
+
+ <div class="manualnavbar">
+ <table width="100%">
+ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
+<tr>
+ <td width="30%">
+ <span class="previous"><a href="fminbnd.html">&lt;&lt; fminbnd</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="fminunc.html">fminunc &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+ </body>
+</html>
diff --git a/help/en_US/scilab_en_US_help/fminunc.html b/help/en_US/scilab_en_US_help/fminunc.html
new file mode 100644
index 0000000..97ffdbf
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/fminunc.html
@@ -0,0 +1,178 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>fminunc</title>
+ <style type="text/css" media="all">
+ @import url("scilab_code.css");
+ @import url("xml_code.css");
+ @import url("c_code.css");
+ @import url("style.css");
+ </style>
+ </head>
+ <body>
+ <div class="manualnavbar">
+ <table width="100%"><tr>
+ <td width="30%">
+ <span class="previous"><a href="fmincon.html">&lt;&lt; fmincon</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="linprog.html">linprog &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+
+
+
+ <span class="path"><a href="index.html">Symphony Toolbox</a> &gt;&gt; <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> &gt; fminunc</span>
+
+ <br /><br />
+ <div class="refnamediv"><h1 class="refname">fminunc</h1>
+ <p class="refpurpose">Solves a multi-variable unconstrainted optimization problem</p></div>
+
+
+<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3>
+ <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">fminunc</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">fminunc</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">options</span><span class="default">)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">] = </span><span class="functionid">fminunc</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">]= </span><span class="functionid">fminunc</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">]= </span><span class="functionid">fminunc</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">gradient</span><span class="default">]=</span><span class="functionid">fminunc</span><span class="default">(.....)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">gradient</span><span class="default">,</span><span class="default">hessian</span><span class="default">]=</span><span class="functionid">fminunc</span><span class="default">(.....)</span></pre></div></div>
+
+<div class="refsection"><h3 class="title">Parameters</h3>
+ <dl><dt><span class="term">f :</span>
+ <dd><p class="para">a function, representing the objective function of the problem</p></dd></dt>
+ <dt><span class="term">x0 :</span>
+ <dd><p class="para">a vector of doubles, containing the starting of variables.</p></dd></dt>
+ <dt><span class="term">options:</span>
+ <dd><p class="para">a list, containing the option for user to specify. See below for details.</p></dd></dt>
+ <dt><span class="term">xopt :</span>
+ <dd><p class="para">a vector of doubles, the computed solution of the optimization problem.</p></dd></dt>
+ <dt><span class="term">fopt :</span>
+ <dd><p class="para">a scalar of double, the function value at x.</p></dd></dt>
+ <dt><span class="term">exitflag :</span>
+ <dd><p class="para">a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.</p></dd></dt>
+ <dt><span class="term">output :</span>
+ <dd><p class="para">a structure, containing the information about the optimization. See below for details.</p></dd></dt>
+ <dt><span class="term">gradient :</span>
+ <dd><p class="para">a vector of doubles, containing the the gradient of the solution.</p></dd></dt>
+ <dt><span class="term">hessian :</span>
+ <dd><p class="para">a matrix of doubles, containing the the hessian of the solution.</p></dd></dt></dl></div>
+
+<div class="refsection"><h3 class="title">Description</h3>
+ <p class="para">Search the minimum of an unconstrained optimization problem specified by :
+Find the minimum of f(x) such that</p>
+ <p class="para"><span><img src='./_LaTeX_fminunc.xml_1.png' style='position:relative;top:9px;width:115px;height:26px'/></span></p>
+ <p class="para">The routine calls Ipopt for solving the Un-constrained Optimization problem, Ipopt is a library written in C++.</p>
+ <p class="para">The options allows the user to set various parameters of the Optimization problem.
+It should be defined as type &#0034;list&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>Syntax : options= list(&#0034;MaxIter&#0034;, [---], &#0034;CpuTime&#0034;, [---], &#0034;Gradient&#0034;, ---, &#0034;Hessian&#0034;, ---);</li>
+<li>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</li>
+<li>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</li>
+<li>Gradient : a function, representing the gradient function of the Objective in Vector Form.</li>
+<li>Hessian : a function, representing the hessian function of the Objective in Symmetric Matrix Form.</li>
+<li>Default Values : options = list(&#0034;MaxIter&#0034;, [3000], &#0034;CpuTime&#0034;, [600]);</li></ul></p>
+ <p class="para">The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<ul class="itemizedlist"><li>exitflag=0 : Optimal Solution Found</li>
+<li>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</li>
+<li>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</li>
+<li>exitflag=3 : Stop at Tiny Step.</li>
+<li>exitflag=4 : Solved To Acceptable Level.</li>
+<li>exitflag=5 : Converged to a point of local infeasibility.</li></ul></p>
+ <p class="para">For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/</p>
+ <p class="para">The output data structure contains detailed informations about the optimization process.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>output.Iterations: The number of iterations performed during the search</li>
+<li>output.Cpu_Time: The total cpu-time spend during the search</li>
+<li>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</li>
+<li>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</li></ul></p>
+ <p class="para"></p></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^2 such that it minimizes the Rosenbrock function</span>
+<span class="scilabcomment">//f = 100*(x2 - x1^2)^2 + (1-x1)^2</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabnumber">100</span><span class="scilaboperator">*</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> <span class="scilaboperator">-</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">+</span> <span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Gradient of objective function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">400</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> <span class="scilaboperator">+</span> <span class="scilabnumber">400</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">3</span> <span class="scilaboperator">+</span> <span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilabnumber">200</span><span class="scilaboperator">*</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Hessian of Objective Function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fHess</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1200</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilaboperator">-</span> <span class="scilabnumber">400</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> <span class="scilaboperator">+</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span> <span class="scilaboperator">-</span><span class="scilabnumber">400</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">400</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span> <span class="scilabnumber">200</span> <span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Gradient</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fGrad</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Hessian</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fHess</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">gradient</span><span class="scilabdefault">,</span><span class="scilabid">hessian</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">fminunc</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span><span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^2 such that the below function is minimum</span>
+<span class="scilabcomment">//f = x1^2 + x2^2</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">+</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">fminunc</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span><span class="scilabid">x0</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//The below problem is an unbounded problem:</span>
+<span class="scilabcomment">//Find x in R^2 such that the below function is minimum</span>
+<span class="scilabcomment">//f = - x1^2 - x2^2</span>
+<span class="scilabcomment">//Objective function to be minimised</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">f</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilaboperator">-</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span> <span class="scilaboperator">-</span> <span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilaboperator">^</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Starting point</span>
+<span class="scilabid">x0</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Gradient of objective function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fGrad</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilaboperator">*</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">(</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Hessian of Objective Function</span>
+<span class="scilabfkeyword">function</span> <span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span><span class="scilabfunctionid">fHess</span><span class="scilabopenclose">(</span><span class="scilabinputoutputargs">x</span><span class="scilabopenclose">)</span>
+<span class="scilabinputoutputargs">y</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span>
+<span class="scilabfkeyword">endfunction</span>
+<span class="scilabcomment">//Options</span>
+<span class="scilabid">options</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0034;</span><span class="scilabstring">MaxIter</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">CpuTime</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabopenclose">[</span><span class="scilabnumber">500</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Gradient</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fGrad</span><span class="scilabdefault">,</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">Hessian</span><span class="scilabstring">&#0034;</span><span class="scilabdefault">,</span> <span class="scilabfunctionid">fHess</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabcomment">//Calling Ipopt</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">gradient</span><span class="scilabdefault">,</span><span class="scilabid">hessian</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">fminunc</span><span class="scilabopenclose">(</span><span class="scilabfunctionid">f</span><span class="scilabdefault">,</span><span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Authors</h3>
+ <ul class="itemizedlist"><li class="member">R.Vidyadhar , Vignesh Kannan</li></ul></div>
+ <br />
+
+ <div class="manualnavbar">
+ <table width="100%">
+ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
+<tr>
+ <td width="30%">
+ <span class="previous"><a href="fmincon.html">&lt;&lt; fmincon</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="linprog.html">linprog &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+ </body>
+</html>
diff --git a/help/en_US/scilab_en_US_help/index.html b/help/en_US/scilab_en_US_help/index.html
index 03ce98c..fc07de0 100644
--- a/help/en_US/scilab_en_US_help/index.html
+++ b/help/en_US/scilab_en_US_help/index.html
@@ -32,7 +32,37 @@
<ul class="list-part"><a name="symphony_toolbox_manual"></a><div class="info"></div>
<li><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html" class="part">Symphony Toolbox</a>
-<ul class="list-chapter"><li><a href="lsqlin.html" class="refentry">lsqlin</a> &#8212; <span class="refentry-description">Solves a linear quadratic problem.</span></li>
+<ul class="list-chapter"><li><a href="fgoalattain.html" class="refentry">fgoalattain</a> &#8212; <span class="refentry-description">Solves a multiobjective goal attainment problem</span></li>
+
+
+
+
+
+<li><a href="fminbnd.html" class="refentry">fminbnd</a> &#8212; <span class="refentry-description">Solves a multi-variable optimization problem on a bounded interval</span></li>
+
+
+
+
+
+<li><a href="fmincon.html" class="refentry">fmincon</a> &#8212; <span class="refentry-description">Solves a multi-variable constrainted optimization problem</span></li>
+
+
+
+
+
+<li><a href="fminunc.html" class="refentry">fminunc</a> &#8212; <span class="refentry-description">Solves a multi-variable unconstrainted optimization problem</span></li>
+
+
+
+
+
+<li><a href="linprog.html" class="refentry">linprog</a> &#8212; <span class="refentry-description">Solves a linear programming problem.</span></li>
+
+
+
+
+
+<li><a href="lsqlin.html" class="refentry">lsqlin</a> &#8212; <span class="refentry-description">Solves a linear quadratic problem.</span></li>
diff --git a/help/en_US/scilab_en_US_help/jhelpmap.jhm b/help/en_US/scilab_en_US_help/jhelpmap.jhm
index 0226c5e..be43c6e 100644
--- a/help/en_US/scilab_en_US_help/jhelpmap.jhm
+++ b/help/en_US/scilab_en_US_help/jhelpmap.jhm
@@ -3,6 +3,11 @@
<map version="1.0">
<mapID target="index" url="index.html"/>
<mapID target="section_19f4f1e5726c01d683e8b82be0a7e910" url="section_19f4f1e5726c01d683e8b82be0a7e910.html"/>
+<mapID target="fgoalattain" url="fgoalattain.html"/>
+<mapID target="fminbnd" url="fminbnd.html"/>
+<mapID target="fmincon" url="fmincon.html"/>
+<mapID target="fminunc" url="fminunc.html"/>
+<mapID target="linprog" url="linprog.html"/>
<mapID target="lsqlin" url="lsqlin.html"/>
<mapID target="lsqnonneg" url="lsqnonneg.html"/>
<mapID target="qpipopt" url="qpipopt.html"/>
diff --git a/help/en_US/scilab_en_US_help/jhelptoc.xml b/help/en_US/scilab_en_US_help/jhelptoc.xml
index f53e713..500c6b0 100644
--- a/help/en_US/scilab_en_US_help/jhelptoc.xml
+++ b/help/en_US/scilab_en_US_help/jhelptoc.xml
@@ -3,6 +3,11 @@
<toc version="1.0">
<tocitem target="index" text="Symphony Toolbox">
<tocitem target="section_19f4f1e5726c01d683e8b82be0a7e910" text="Symphony Toolbox">
+<tocitem target="fgoalattain" text="fgoalattain"/>
+<tocitem target="fminbnd" text="fminbnd"/>
+<tocitem target="fmincon" text="fmincon"/>
+<tocitem target="fminunc" text="fminunc"/>
+<tocitem target="linprog" text="linprog"/>
<tocitem target="lsqlin" text="lsqlin"/>
<tocitem target="lsqnonneg" text="lsqnonneg"/>
<tocitem target="qpipopt" text="qpipopt"/>
diff --git a/help/en_US/scilab_en_US_help/linprog.html b/help/en_US/scilab_en_US_help/linprog.html
new file mode 100644
index 0000000..260b8b3
--- /dev/null
+++ b/help/en_US/scilab_en_US_help/linprog.html
@@ -0,0 +1,188 @@
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>linprog</title>
+ <style type="text/css" media="all">
+ @import url("scilab_code.css");
+ @import url("xml_code.css");
+ @import url("c_code.css");
+ @import url("style.css");
+ </style>
+ </head>
+ <body>
+ <div class="manualnavbar">
+ <table width="100%"><tr>
+ <td width="30%">
+ <span class="previous"><a href="fminunc.html">&lt;&lt; fminunc</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="lsqlin.html">lsqlin &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+
+
+
+ <span class="path"><a href="index.html">Symphony Toolbox</a> &gt;&gt; <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> &gt; linprog</span>
+
+ <br /><br />
+ <div class="refnamediv"><h1 class="refname">linprog</h1>
+ <p class="refpurpose">Solves a linear programming problem.</p></div>
+
+
+<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3>
+ <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">linprog</span><span class="default">(</span><span class="default">c</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">linprog</span><span class="default">(</span><span class="default">c</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">linprog</span><span class="default">(</span><span class="default">c</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span>
+<span class="default">xopt</span><span class="default"> = </span><span class="functionid">linprog</span><span class="default">(</span><span class="default">c</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">param</span><span class="default">)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">, </span><span class="default">fopt</span><span class="default">, </span><span class="default">exitflag</span><span class="default">, </span><span class="default">output</span><span class="default">, </span><span class="default">lambda</span><span class="default">] = </span><span class="functionid">linprog</span><span class="default">(</span><span class="default">file</span><span class="default">)</span>
+<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lambda</span><span class="default">] = </span><span class="functionid">linprog</span><span class="default">( ... )</span></pre></div></div>
+
+<div class="refsection"><h3 class="title">Parameters</h3>
+ <dl><dt><span class="term">c :</span>
+ <dd><p class="para">a vector of double, contains coefficients of the variables in the objective</p></dd></dt>
+ <dt><span class="term">A :</span>
+ <dd><p class="para">a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</p></dd></dt>
+ <dt><span class="term">b :</span>
+ <dd><p class="para">a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.</p></dd></dt>
+ <dt><span class="term">Aeq :</span>
+ <dd><p class="para">a matrix of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.</p></dd></dt>
+ <dt><span class="term">beq :</span>
+ <dd><p class="para">a vector of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.</p></dd></dt>
+ <dt><span class="term">lb :</span>
+ <dd><p class="para">Lower bounds, specified as a vector or array of double. lb represents the lower bounds elementwise in lb ≤ x ≤ ub.</p></dd></dt>
+ <dt><span class="term">ub :</span>
+ <dd><p class="para">Upper bounds, specified as a vector or array of double. ub represents the upper bounds elementwise in lb ≤ x ≤ ub.</p></dd></dt>
+ <dt><span class="term">options :</span>
+ <dd><p class="para">a list containing the parameters to be set.</p></dd></dt>
+ <dt><span class="term">file :</span>
+ <dd><p class="para">a string describing the path to the mps file.</p></dd></dt>
+ <dt><span class="term">xopt :</span>
+ <dd><p class="para">a vector of double, the computed solution of the optimization problem.</p></dd></dt>
+ <dt><span class="term">fopt :</span>
+ <dd><p class="para">a double, the value of the function at x.</p></dd></dt>
+ <dt><span class="term">status :</span>
+ <dd><p class="para">status flag returned from symphony. See below for details.</p></dd></dt>
+ <dt><span class="term">output :</span>
+ <dd><p class="para">The output data structure contains detailed information about the optimization process. See below for details.</p></dd></dt>
+ <dt><span class="term">lambda :</span>
+ <dd><p class="para">The structure consist of the Lagrange multipliers at the solution of problem. See below for details.</p></dd></dt></dl></div>
+
+<div class="refsection"><h3 class="title">Description</h3>
+ <p class="para">OSI-CLP is used for solving the linear programming problems, OSI-CLP is a library written in C++.
+Search the minimum of a constrained linear programming problem specified by :</p>
+ <p class="para"><span><img src='./_LaTeX_linprog.xml_1.png' style='position:relative;top:40px;width:212px;height:88px'/></span>
+The routine calls Clp for solving the linear programming problem, Clp is a library written in C++.</p>
+ <p class="para">The exitflag allows to know the status of the optimization which is given back by Ipopt.
+<ul class="itemizedlist"><li>exitflag=0 : Optimal Solution Found</li>
+<li>exitflag=1 : Primal Infeasible</li>
+<li>exitflag=2 : Dual Infeasible</li>
+<li>exitflag=3 : Maximum Number of Iterations Exceeded. Output may not be optimal.</li>
+<li>exitflag=4 : Solution Abandoned</li>
+<li>exitflag=5 : Primal objective limit reached.</li>
+<li>exitflag=6 : Dual objective limit reached.</li></ul></p>
+ <p class="para">For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/</p>
+ <p class="para">The output data structure contains detailed informations about the optimization process.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>output.iterations: The number of iterations performed during the search</li>
+<li>output.constrviolation: The max-norm of the constraint violation.</li></ul></p>
+ <p class="para">The lambda data structure contains the Lagrange multipliers at the end
+of optimization. In the current version the values are returned only when the the solution is optimal.
+It has type &#0034;struct&#0034; and contains the following fields.
+<ul class="itemizedlist"><li>lambda.lower: The Lagrange multipliers for the lower bound constraints.</li>
+<li>lambda.upper: The Lagrange multipliers for the upper bound constraints.</li>
+<li>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</li>
+<li>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</li></ul></p>
+ <p class="para"></p></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Optimal problems</span>
+<span class="scilabcomment">//Linear program, linear inequality constraints</span>
+<span class="scilabid">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilaboperator">&#0039;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span> <span class="scilabid">A</span><span class="scilabdefault">,</span> <span class="scilabid">b</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">// Press ENTER to continue</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Linear program with Linear Inequalities and Equalities`</span>
+<span class="scilabid">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilaboperator">&#0039;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span> <span class="scilabid">A</span><span class="scilabdefault">,</span> <span class="scilabid">b</span><span class="scilabdefault">,</span> <span class="scilabid">Aeq</span><span class="scilabdefault">,</span> <span class="scilabid">beq</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">// Press ENTER to continue</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Linear program with all constraint types</span>
+<span class="scilabid">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilaboperator">&#0039;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilaboperator">/</span><span class="scilabnumber">2</span><span class="scilabopenclose">]</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">0.5</span><span class="scilabopenclose">]</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1.5</span><span class="scilabdefault">,</span><span class="scilabnumber">1.25</span><span class="scilabopenclose">]</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span> <span class="scilabid">A</span><span class="scilabdefault">,</span> <span class="scilabid">b</span><span class="scilabdefault">,</span> <span class="scilabid">Aeq</span><span class="scilabdefault">,</span> <span class="scilabid">beq</span><span class="scilabdefault">,</span> <span class="scilabid">lb</span><span class="scilabdefault">,</span> <span class="scilabid">ub</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">// Press ENTER to continue</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Primal Infeasible Problem</span>
+<span class="scilabid">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilaboperator">&#0039;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabopenclose">]</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">10</span><span class="scilabdefault">,</span><span class="scilabnumber">100</span><span class="scilabopenclose">]</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span> <span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">// Press ENTER to continue</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Dual Infeasible Problem</span>
+<span class="scilabid">c</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">7</span><span class="scilabopenclose">]</span><span class="scilaboperator">&#0039;</span>
+<span class="scilabid">A</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabdefault">;</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span>
+<span class="scilabid">b</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">8</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabopenclose">]</span>
+<span class="scilabid">Aeq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span>
+<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span>
+<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span>
+<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span> <span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span>
+<span class="scilabcomment">// Press ENTER to continue</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Examples</h3>
+ <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabid">filepath</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://get_absolute_file_path">get_absolute_file_path</a><span class="scilabopenclose">(</span><span class="scilabstring">&#0039;</span><span class="scilabstring">linprog.dem.sce</span><span class="scilabstring">&#0039;</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
+<span class="scilabid">filepath</span> <span class="scilaboperator">=</span> <span class="scilabid">filepath</span> <span class="scilaboperator">+</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">exmip1.mps</span><span class="scilabstring">&#0034;</span>
+<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span><span class="scilabid">linprog</span><span class="scilabopenclose">(</span><span class="scilabid">filepath</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>
+
+<div class="refsection"><h3 class="title">Authors</h3>
+ <ul class="itemizedlist"><li class="member">Bhanu Priya Sayal, Guru Pradeep Reddy</li></ul></div>
+ <br />
+
+ <div class="manualnavbar">
+ <table width="100%">
+ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
+<tr>
+ <td width="30%">
+ <span class="previous"><a href="fminunc.html">&lt;&lt; fminunc</a></span>
+
+ </td>
+ <td width="40%" class="center">
+ <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span>
+
+ </td>
+ <td width="30%" class="next">
+ <span class="next"><a href="lsqlin.html">lsqlin &gt;&gt;</a></span>
+
+ </td>
+ </tr></table>
+ <hr />
+ </div>
+ </body>
+</html>
diff --git a/help/en_US/scilab_en_US_help/lsqlin.html b/help/en_US/scilab_en_US_help/lsqlin.html
index db24b63..eb1b38d 100644
--- a/help/en_US/scilab_en_US_help/lsqlin.html
+++ b/help/en_US/scilab_en_US_help/lsqlin.html
@@ -12,7 +12,7 @@
<div class="manualnavbar">
<table width="100%"><tr>
<td width="30%">
- <span class="previous"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">&lt;&lt; Symphony Toolbox</a></span>
+ <span class="previous"><a href="linprog.html">&lt;&lt; linprog</a></span>
</td>
<td width="40%" class="center">
@@ -151,7 +151,7 @@ It has type &#0034;struct&#0034; and contains the following fields.
<tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
<tr>
<td width="30%">
- <span class="previous"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">&lt;&lt; Symphony Toolbox</a></span>
+ <span class="previous"><a href="linprog.html">&lt;&lt; linprog</a></span>
</td>
<td width="40%" class="center">
diff --git a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html
index a79bad0..a03f091 100644
--- a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html
+++ b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html
@@ -31,7 +31,37 @@
<br /><br />
<h3 class="title-part">Symphony Toolbox</h3>
-<ul class="list-chapter"><li><a href="lsqlin.html" class="refentry">lsqlin</a> &#8212; <span class="refentry-description">Solves a linear quadratic problem.</span></li>
+<ul class="list-chapter"><li><a href="fgoalattain.html" class="refentry">fgoalattain</a> &#8212; <span class="refentry-description">Solves a multiobjective goal attainment problem</span></li>
+
+
+
+
+
+<li><a href="fminbnd.html" class="refentry">fminbnd</a> &#8212; <span class="refentry-description">Solves a multi-variable optimization problem on a bounded interval</span></li>
+
+
+
+
+
+<li><a href="fmincon.html" class="refentry">fmincon</a> &#8212; <span class="refentry-description">Solves a multi-variable constrainted optimization problem</span></li>
+
+
+
+
+
+<li><a href="fminunc.html" class="refentry">fminunc</a> &#8212; <span class="refentry-description">Solves a multi-variable unconstrainted optimization problem</span></li>
+
+
+
+
+
+<li><a href="linprog.html" class="refentry">linprog</a> &#8212; <span class="refentry-description">Solves a linear programming problem.</span></li>
+
+
+
+
+
+<li><a href="lsqlin.html" class="refentry">lsqlin</a> &#8212; <span class="refentry-description">Solves a linear quadratic problem.</span></li>
diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar
index 0289144..970425b 100644
--- a/jar/scilab_en_US_help.jar
+++ b/jar/scilab_en_US_help.jar
Binary files differ
diff --git a/macros/fgoalattain.bin b/macros/fgoalattain.bin
new file mode 100644
index 0000000..1476d8e
--- /dev/null
+++ b/macros/fgoalattain.bin
Binary files differ
diff --git a/macros/fgoalattain.sci b/macros/fgoalattain.sci
new file mode 100644
index 0000000..5f519b4
--- /dev/null
+++ b/macros/fgoalattain.sci
@@ -0,0 +1,514 @@
+// 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
+
+function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin)
+ // Solves a multiobjective goal attainment problem
+ //
+ // Calling Sequence
+ // x = fgoalattain(fun,x0,goal,weight)
+ // x = fgoalattain(fun,x0,goal,weight,A,b)
+ // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq)
+ // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub)
+ // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon)
+ // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,options)
+ // [x,fval] = fgoalattain(...)
+ // [x,fval,attainfactor] = fgoalattain(...)
+ // [x,fval,attainfactor,exitflag] = fgoalattain(...)
+ // [x,fval,attainfactor,exitflag,output] = fgoalattain(...)
+ // [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...)
+ //
+ // Parameters
+ // fun: a function that accepts a vector x and returns a vector F
+ // x0: a nx1 or 1xn matrix of double, where n is the number of variables.
+ // The initial guess for the optimization algorithm
+ // A: a nil x n matrix of double, where n is the number of variables and
+ // nil is the number of linear inequalities.
+ //
+ // b: a nil x 1 matrix of double, where nil is the number of linear
+ // inequalities
+ // Aeq: a nel x n matrix of double, where n is the number of variables
+ // and nel is the number of linear equalities.
+ // beq: a nel x 1 matrix of double, where nel is the number of linear
+ // equalities
+ // lb: a nx1 or 1xn matrix of double, where n is the number of variables.
+ // The lower bound for x. If lb==[], then the lower bound is
+ // automatically set to -inf
+ // ub: a nx1 or 1xn matrix of double, where n is the number of variables.
+ // The upper bound for x. If ub==[], then the upper bound is
+ // automatically set to +inf
+ // nonlcon: a function, the nonlinear constraints
+ // options : a list, containing the option for user to specify. See below for details.
+ // x: a nx1 matrix of double, the computed solution of the optimization problem
+ // fval: a vector of double, the value of functions at x
+ // attainfactor: The amount of over- or underachievement of the goals,γ at the solution.
+ // exitflag: a 1x1 matrix of floating point integers, the exit status
+ // output: a struct, the details of the optimization process
+ // lambda: a struct, the Lagrange multipliers at optimum
+ //
+ // Description
+ // fgoalattain solves the goal attainment problem, which is one formulation for minimizing a multiobjective optimization problem.
+ // Finds the minimum of a problem specified by:
+ // Minimise Y such that
+ //
+ //<latex>
+ //\begin{eqnarray}
+ //\mbox{min}_{x,\gamma} & f(x)-weight \ast \gamma \leq goal \\
+ //\mbox{subject to} & c(x) \leq 0 \\
+ // & c_{eq}(x) = 0 \\
+ // & Ax \leq b \\
+ // & A_{eq} x = b_{eq} \\
+ // & lb \leq x \leq ub
+ //\end{eqnarray}
+ //</latex>
+ //
+ // The solver makes use of fmincon to find the minimum.
+ //
+ // The fgoalattain finds out the maximum value of Y for the objectives evaluated at the starting point and
+ // adds that as another variable to the vector x
+ // This is passed to the fmincon function to get the optimised value of Y
+ // Hence, the algorithm used mainly is "ipopt" to obtain the optimum solution
+ // The relations between f(x), Y, weights and goals are added as additional non-linear inequality constraints
+ //
+ // The options allows the user to set various parameters of the Optimization problem.
+ // It should be defined as type "list" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "GradCon", ---);</listitem>
+ // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+ // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+ // <listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+ // <listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 & m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+ // <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.
+ //
+ // If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ //
+ // Furthermore, we must enable the "GradObj" option with the statement :
+ // <programlisting>
+ // minimaxOptions = list("GradObj",fGrad);
+ // </programlisting>
+ // This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function. Note that, fGrad should be mentioned in the form of N x n where n is the number of variables, N is the number of functions in objective function.
+ //
+ // The constraint function must have header :
+ // <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).
+ // 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.
+ //
+ // If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ //
+ // Furthermore, we must enable the "GradCon" option with the statement :
+ // <programlisting>
+ // minimaxOptions = list("GradCon",confunGrad);
+ // </programlisting>
+ // This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function.
+ //
+ // The constraint derivative function must have header :
+ // <programlisting>
+ // [dc,dceq] = confungrad(x)
+ // </programlisting>
+ // where dc is a nni x n matrix of doubles and dceq is a nne x n matrix of doubles.
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+ // <listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+ // <listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.Iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+ // <listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+ // <listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+ // </itemizedlist>
+ //
+ // The lambda data structure contains the Lagrange multipliers at the end
+ // of optimization. In the current version the values are returned only when the the solution is optimal.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+ // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+ // <listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+ // <listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+ // <listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+ // <listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // function f1 = fun(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
+ // f1(4)=-x(1)-x(2)
+ // f1(5)=x(1)+x(2)-8
+ // endfunction
+ // x0=[-1,1];
+ //
+ // goal=[-5,-3,-2,-1,-4];
+ // weight=abs(goal)
+ // //xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
+ // //fval = [4 3.99]
+ //
+ // //Run fgoalattain
+ // [xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,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)
+
+ // initialisation of fun
+ gattainObjfun = varargin(1)
+ fgoalattainChecktype("fgoalattain", gattainObjfun, "fun", 1, "function")
+
+ // initialisation of x0
+ gattainStartpoint = varargin(2)
+ fgoalattainChecktype("fgoalattain", gattainStartpoint, "x0", 2, "constant")
+
+ gattainNumvar = size(gattainStartpoint,"*")
+ fgoalattainCheckvector("fgoalattain", gattainStartpoint, "x0", 2, gattainNumvar)
+ gattainStartpoint = gattainStartpoint(:)
+
+ // initialisation of goal
+ goal=varargin(3)
+ fgoalattainChecktype("fgoalattain",goal,"goal",3,"constant")
+
+ // initialisation of weight
+ weight=varargin(4)
+ fgoalattainChecktype("fgoalattain",weight,"weight",4,"constant")
+
+ //initialisation of A and b
+ if(gattainRhs < 5) then
+ gattainA = []
+ gattainB = []
+ else
+ gattainA = varargin(5)
+ gattainB = varargin(6)
+ end
+
+ fgoalattainChecktype("fgoalattain", gattainA, "A", 5, "constant")
+ fgoalattainChecktype("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)
+ gattainB = gattainB(:)
+ end
+
+ //initialisation of Aeq and beq
+ if(gattainRhs < 7) then
+ gattainAeq = []
+ gattainBeq = []
+ else
+ gattainAeq = varargin(7)
+ gattainBeq = varargin(8)
+ end
+
+ fgoalattainChecktype("fgoalattain", gattainAeq, "Aeq", 7, "constant")
+ fgoalattainChecktype("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)
+ gattainBeq = gattainBeq(:)
+ end
+
+ // initialisation of lb and ub
+ if(gattainRhs < 9) then
+ gattainLb = []
+ gattainUb = []
+ else
+ gattainLb = varargin(9)
+ gattainUb = varargin(10)
+ end
+
+ fgoalattainChecktype("fgoalattain", gattainLb, "lb", 9, "constant")
+ fgoalattainChecktype("fgoalattain", gattainUb, "ub", 10, "constant")
+
+ // Check dimensions of lb and ub
+ if(gattainLb <> []) then
+ fgoalattainCheckvector("fgoalattain", gattainLb, "lb", 9, gattainNumvar)
+ gattainLb = gattainLb(:)
+ end
+
+ if(gattainUb <> []) then
+ fgoalattainCheckvector("fgoalattain", gattainUb, "ub", 10, gattainNumvar)
+ gattainUb = gattainUb(:)
+ end
+
+ // Initialisation of nonlcon
+ function [c,ceq] = constr(z)
+ c = []
+ ceq = []
+ endfunction
+
+ if(gattainRhs < 11) then
+ gattainNonlinfun = constr
+ else
+ gattainNonlinfun = varargin(11)
+ end
+
+ fgoalattainChecktype("fgoalattain", gattainNonlinfun, "nonlcon", 11, "function")
+
+ // initialisation of default options
+ if(gattainRhs < 12) then
+ gattainUserOptions = list()
+ else
+ gattainUserOptions = varargin(12)
+ end
+
+ //If gattainOptions is entered then checking its type for 'list'
+ if (type(gattainUserOptions) ~= 15) then
+ errmsg = msprintf(gettext("%s: gattainOptions (10th parameter) should be a list"), "fgoalattain");
+ error(errmsg);
+ end
+
+ //If minimaxOptions is entered then checking whether even number of entires are entered
+ if (modulo(size(gattainUserOptions),2)) then
+ errmsg = msprintf(gettext("%s: Size of gattainOptions (list) should be even"), "fgoalattain");
+ error(errmsg);
+ end
+
+ //Flags to check whether Gradient is "ON"/"OFF" & Hessian is "ON"/"OFF"
+ flag1=0;
+ flag2=0;
+ fgaMaxIter = 3000;
+ fgaCPU = 600;
+ gattainFGrad=[];
+ gattainCGrad=[];
+
+ //To check the User Entry for Options and storing it
+ for i = 1:(size(gattainUserOptions))/2
+ select gattainUserOptions(2*i-1)
+ case "MaxIter" then
+ fgaMaxIter = gattainUserOptions(2*i); //Setting the Maximum Iteration as per user entry
+
+ case "CpuTime" then
+ fgaCPU = gattainUserOptions(2*i); //Setting the Maximum CPU Time as per user entry
+
+ case "GradObj" then
+ flag1=1;
+ gattainFGrad = gattainUserOptions(2*i);
+
+ case "GradCon" then
+ flag2=1;
+ gattainCGrad = gattainUserOptions(2*i);
+
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized gattainUserOptionseter name ''%s''."), "fminimax", gattainUserOptions(2*i-1));
+ error(errmsg)
+ end
+ end
+
+ // Checking if minmaxFGrad and minmaxCGrad 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");
+ error(errmsg);
+ end
+ end
+
+ if (flag2==1) then
+ if (type(gattainCGrad) ~= 11 & type(gattainCGrad) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Nonlinfun"), "fminimax");
+ error(errmsg);
+ end
+ end
+
+ gattainObjfunval = gattainObjfun(gattainStartpoint)
+ gattainObjfunval=gattainObjfunval(:)
+ goal=goal(:)
+ weight=weight(:)
+ gaVal=[]
+
+ // appending the gamma value as another variable
+ for i=1:size(gattainObjfunval,'r')
+ if(weight(i)<>0) then
+ gaVal(i)=((gattainObjfunval(i)-goal(i))/weight(i))
+ end
+ end
+
+ gattainStartpoint(gattainNumvar+1)=max(gaVal)
+
+ if(gattainA <> []) then
+ gattainA = [gattainA, zeros(gattainNumrowA,1)]
+ end
+ if(gattainAeq <> []) then
+ gattainAeq = [gattainAeq, zeros(gattainNumrowAeq,1)]
+ end
+ if(gattainLb <> []) then
+ gattainLb(gattainNumvar+1) = -%inf
+ end
+ if(gattainUb <> []) then
+ gattainUb(gattainNumvar+1) = +%inf
+ end
+
+ // function handle defining the additional inequalities
+ function temp = gattainAddIneq(z)
+ gaVar = gattainObjfun(z)
+ gattainAddIneqWithWt = []
+ gattainAddIneqWitoutWt = []
+ for i = 1:size(gaVar,'r')
+ if(weight(i) <> 0) then
+ gattainAddIneqWithWt = [gattainAddIneqWithWt; ( (gaVar(i)-goal(i))/weight(i) )]
+ else
+ gattainAddIneqWitoutWt = [gattainAddIneqWitoutWt; gaVar(i)-goal(i)]
+ end
+ end
+ temp = [gattainAddIneqWithWt - z(gattainNumvar+1); gattainAddIneqWitoutWt]
+ endfunction
+
+ // function handle defining new objective function
+ function newfunc = newObjfun(z)
+ newfunc = z(gattainNumvar+1)
+ endfunction
+
+ // function handle defining add_ineq derivative using numderivative
+ function func = gattainIneqDer(z)
+ func = numderivative(gattainAddIneq,z)
+ endfunction
+
+ // function handle defining nonlcon derivative using numderivative
+ function [dc,dceq] = gattainNonlinDer(z)
+
+ // function handle extracting c and ceq components from nonlcon
+ function foo = gattainC(z)
+ [foo,tmp1] = gattainNonlinfun(z)
+ foo = foo'
+ endfunction
+
+ function foo = gattainCEQ(z)
+ [tmp1,foo] = gattainNonlinfun(z)
+ foo = foo'
+ endfunction
+
+ dc = numderivative(gattainC,z)
+ dceq = numderivative(gattainCEQ,z)
+ endfunction
+
+ // function handle defining new nonlcon function
+ function [nc,nceq] = newNonlinfun(z)
+ [nc,nceq] = gattainNonlinfun(z)
+ tmp = [gattainAddIneq(z)]'
+ nc = [nc, tmp]
+ endfunction
+
+ function [dnc,dnceq] = newCGrad(z)
+ // check if "GradCon" option is turned on
+ // if "GradCon" is turned on, use it
+ if(flag2 == 1) then
+ [dnc,dnceq] = gattainCGrad(z)
+ dnc = [dnc, zeros(size(dnc,'r'),1)]
+ dnceq = [dnceq, zeros(size(dnceq,'r'),1)]
+ // else, calculate it using finite differences
+ else
+ [dnc,dnceq] = gattainNonlinDer(z)
+ end
+
+ // check if "GradObj" option is turned on
+ // if "GradObj" is turned on, use it
+ if(flag1 == 1) then
+ derObjfun = gattainFGrad(z)
+ tmp1 = []
+ tmp2 = []
+ for i = 1:size(gattainObjfun(gattainStartpoint),'r')
+ if weight(i) <> 0 then
+ gaVal = [derObjfun(i,:)/weight(i) , -1]
+ tmp1 = [ tmp1; gaVal ]
+ else
+ gaVal = [derObjfun(i,:) , 0]
+ tmp2 = [ tmp2; gaVal ]
+ end
+ end
+
+ dnc = [ dnc; tmp1; tmp2 ]
+ // else, calculate it using finite differences
+ else
+ deraddineq = gattainIneqDer(z)
+ dnc = [dnc; deraddineq]
+ end
+ endfunction
+
+
+ // disp(gattainStartpoint)
+ // disp(gattainObjfun(gattainStartpoint))
+ // disp(newObjfun(gattainStartpoint))
+ // disp(goal)
+ // disp(weight)
+ //
+ // disp(gattainA)
+ // disp(gattainB)
+ // disp(gattainAeq)
+ // disp(gattainBeq)
+ // disp(gattainLb)
+ // disp(gattainUb)
+ //
+ // [f,g] = gattainNonlinfun(gattainStartpoint)
+ // disp(f)
+ // disp(g)
+ // [f,g] = newNonlinfun(gattainStartpoint)
+ // disp(f)
+ // disp(g)
+ //
+ // // function foo = CgattainC(z)
+ // // [foo,tmp1] = newNonlinfun(z)
+ // // endfunction
+ // //
+ // // function foo = CgattainCEQ(z)
+ // // [tmp1,foo] = newNonlinfun(z)
+ // // endfunction
+ // //
+ // // // function handle defining gattainNonlinfun derivative using numderivative
+ // // function [dc,dceq] = derrNonlinApp(z)
+ // // dc = numderivative(CgattainC,z)
+ // // dceq = numderivative(CgattainCEQ,z)
+ // // endfunction
+ //
+ // // [f,g] = derrNonlinApp(gattainStartpoint)
+ // // disp(f)
+ // // disp(g)
+ //
+ // [f,g] = newCGrad(gattainStartpoint)
+ // disp(f)
+ // disp(g)
+
+ //to be passed as options to fmincon
+ if (flag1 == 1 | flag2 == 1) then
+ gattainPassOptions = list("MaxIter", fgaMaxIter, "CpuTime", fgaCPU, "GradCon", newCGrad)
+ [x,attainfactor,exitflag,output,lambda] = fmincon(newObjfun,gattainStartpoint,gattainA,gattainB,gattainAeq,gattainBeq,gattainLb,gattainUb,newNonlinfun,gattainPassOptions)
+ x= x(1:gattainNumvar)
+ fval = gattainObjfun(x)
+ else
+ gattainPassOptions = list("MaxIter", fgaMaxIter, "CpuTime", fgaCPU)
+ [x,attainfactor,exitflag,output,lambda] = fmincon(newObjfun,gattainStartpoint,gattainA,gattainB,gattainAeq,gattainBeq,gattainLb,gattainUb,newNonlinfun,gattainPassOptions)
+ x= x(1:gattainNumvar)
+ fval = gattainObjfun(x)
+ end
+
+endfunction
diff --git a/macros/fgoalattainFunctions.bin b/macros/fgoalattainFunctions.bin
new file mode 100644
index 0000000..eb72f4d
--- /dev/null
+++ b/macros/fgoalattainFunctions.bin
Binary files differ
diff --git a/macros/fgoalattainFunctions.sci b/macros/fgoalattainFunctions.sci
new file mode 100644
index 0000000..8745fa6
--- /dev/null
+++ b/macros/fgoalattainFunctions.sci
@@ -0,0 +1,76 @@
+// 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/fminbnd.bin b/macros/fminbnd.bin
new file mode 100644
index 0000000..76db1fb
--- /dev/null
+++ b/macros/fminbnd.bin
Binary files differ
diff --git a/macros/fminbnd.sci b/macros/fminbnd.sci
new file mode 100644
index 0000000..2ebaa8c
--- /dev/null
+++ b/macros/fminbnd.sci
@@ -0,0 +1,356 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// 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
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+
+function [xopt,fopt,exitflag,output,lambda] = fminbnd (varargin)
+ // Solves a multi-variable optimization problem on a bounded interval
+ //
+ // Calling Sequence
+ // xopt = fminbnd(f,x1,x2)
+ // xopt = fminbnd(f,x1,x2,options)
+ // [xopt,fopt] = fminbnd(.....)
+ // [xopt,fopt,exitflag]= fminbnd(.....)
+ // [xopt,fopt,exitflag,output]=fminbnd(.....)
+ // [xopt,fopt,exitflag,output,lambda]=fminbnd(.....)
+ //
+ // Parameters
+ // f : a function, representing the objective function of the problem
+ // x1 : a vector, containing the lower bound of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables, where n is number of Variables
+ // x2 : a vector, containing the upper bound of the variables of size (1 X n) or (n X 1) or (0 X 0) where 'n' is the number of Variables. If x2 is empty it means upper bound is +infinity
+ // options : a list, containing the option for user to specify. See below for details.
+ // xopt : a vector of doubles, containing the the computed solution of the optimization problem.
+ // fopt : a scalar of double, containing the the function value at x.
+ // exitflag : a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
+ // output : a structure, containing the information about the optimization. See below for details.
+ // lambda : a structure, containing the Lagrange multipliers of lower bound and upper bound at the optimized point. See below for details.
+ //
+ // Description
+ // Search the minimum of a multi-variable function on bounded interval specified by :
+ // Find the minimum of f(x) such that
+ //
+ // <latex>
+ // \begin{eqnarray}
+ // &\mbox{min}_{x}
+ // & f(x)\\
+ // & \text{subject to} & x1 \ < x \ < x2 \\
+ // \end{eqnarray}
+ // </latex>
+ //
+ // The routine calls Ipopt for solving the Bounded Optimization problem, Ipopt is a library written in C++.
+ //
+ // The options allows the user to set various parameters of the Optimization problem.
+ // It should be defined as type "list" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], TolX, [----]);</listitem>
+ // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+ // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+ // <listitem>TolX : a Scalar, containing the Tolerance value that the solver should take.</listitem>
+ // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600], TolX, [1e-4]);</listitem>
+ // </itemizedlist>
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+ // <listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+ // <listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.Iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+ // <listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+ // <listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+ // </itemizedlist>
+ //
+ // The lambda data structure contains the Lagrange multipliers at the end
+ // of optimization. In the current version the values are returned only when the the solution is optimal.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+ // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // //Find x in R^6 such that it minimizes:
+ // //f(x)= sin(x1) + sin(x2) + sin(x3) + sin(x4) + sin(x5) + sin(x6)
+ // //-2 <= x1,x2,x3,x4,x5,x6 <= 2
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=0
+ // for i =1:6
+ // y=y+sin(x(i));
+ // end
+ // endfunction
+ // //Variable bounds
+ // x1 = [-2, -2, -2, -2, -2, -2];
+ // x2 = [2, 2, 2, 2, 2, 2];
+ // //Options
+ // options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+ // //Calling Ipopt
+ // [x,fval] =fminbnd(f, x1, x2, options)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Find x in R such that it minimizes:
+ // //f(x)= 1/x^2
+ // //0 <= x <= 1000
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=1/x^2
+ // endfunction
+ // //Variable bounds
+ // x1 = [0];
+ // x2 = [1000];
+ // //Calling Ipopt
+ // [x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //The below problem is an unbounded problem:
+ // //Find x in R^2 such that it minimizes:
+ // //f(x)= -[(x1-1)^2 + (x2-1)^2]
+ // //-inf <= x1,x2 <= inf
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=-((x(1)-1)^2+(x(2)-1)^2);
+ // endfunction
+ // //Variable bounds
+ // x1 = [-%inf , -%inf];
+ // x2 = [];
+ // //Options
+ // options=list("MaxIter",[1500],"CpuTime", [100],"TolX",[1e-6])
+ // //Calling Ipopt
+ // [x,fval,exitflag,output,lambda] =fminbnd(f, x1, x2, options)
+ // Authors
+ // R.Vidyadhar , Vignesh Kannan
+
+
+ //To check the number of input and output arguments
+ [lhs , rhs] = argn();
+
+ //To check the number of arguments given by the user
+ if ( rhs<3 | rhs>4 ) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 3 or 4"), "fminbnd", rhs);
+ error(errmsg)
+ end
+
+ //Storing the 1st and 2nd Input Parameters
+ fun = varargin(1);
+ x1 = varargin(2);
+ x2 = varargin(3);
+
+ //Converting the User defined Objective function into Required form (Error Detectable)
+ function [y,check] = f(x)
+ if(execstr('y=fun(x)','errcatch')==32 | execstr('y=fun(x)','errcatch')==27)
+ y=zeros(1,1);
+ check=1;
+ else
+ if (isreal(y)==%F) then
+ y=zeros(1,1);
+ check=1;
+ else
+ y=fun(x);
+ check=0;
+ end
+ end
+ endfunction
+
+ //To check whether the 2nd Input argument (x1) is a vector/scalar
+ if (type(x1) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Lower Bound Vector (2nd Parameter)"), "fminbnd");
+ error(errmsg);
+ end
+
+ if (size(x1,2)==0) then
+ errmsg = msprintf(gettext("%s: Lower Bound (2nd Parameter) cannot be empty"), "fminbnd");
+ error(errmsg);
+ end
+
+ if (size(x1,1)~=1) & (size(x1,2)~=1) then
+ errmsg = msprintf(gettext("%s: Lower Bound (2nd Parameter) should be a vector"), "fminbnd");
+ error(errmsg);
+ elseif (size(x1,2)==1) then
+ x1=x1;
+ elseif (size(x1,1)==1) then
+ x1=x1';
+ end
+ s=size(x1);
+
+ //To check whether the 3rd Input argument (x2) is a vector/scalar
+ if (type(x2) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Upper Bound Vector (3rd Parameter)"), "fminbnd");
+ error(errmsg);
+ end
+
+ //To check for the correct size and data of x2 (3rd paramter) and convert it to a column vector as required by Ipopt
+ if (size(x2,2)==0) then
+ x2 = repmat(%inf,s(1),1);
+ end
+
+
+ if (size(x2,1)~=1) & (size(x2,2)~=1) then
+ errmsg = msprintf(gettext("%s: Upper Bound (3rd Parameter) should be a vector"), "fminbnd");
+ error(errmsg);
+ elseif(size(x2,1)~=s(1) & size(x2,2)==1) then
+ errmsg = msprintf(gettext("%s: Upper Bound and Lower Bound are not matching"), "fminbnd");
+ error(errmsg);
+ elseif(size(x2,1)==s(1) & size(x2,2)==1) then
+ x2=x2;
+ elseif(size(x2,1)==1 & size(x2,2)~=s(1)) then
+ errmsg = msprintf(gettext("%s: Upper Bound and Lower Bound are not matching"), "fminbnd");
+ error(errmsg);
+ elseif(size(x2,1)==1 & size(x2,2)==s(1)) then
+ x2=x2';
+ end
+
+ //To check the contents of x1 and x2 (2nd & 3rd Parameter)
+
+ for i = 1:s(2)
+ if (x1(i) == %inf) then
+ errmsg = msprintf(gettext("%s: Value of Lower Bound can not be infinity"), "fminbnd");
+ error(errmsg);
+ end
+ if (x2(i) == -%inf) then
+ errmsg = msprintf(gettext("%s: Value of Upper Bound can not be negative infinity"), "fminbnd");
+ error(errmsg);
+ end
+ if(x2(i)-x1(i)<=1e-6) then
+ errmsg = msprintf(gettext("%s: Difference between Upper Bound and Lower bound should be atleast > 10^6 for variable number= %d "), "fminbnd", i);
+ error(errmsg)
+ end
+ end
+
+ //To check, whether options has been entered by the user
+ if ( rhs<4 | size(varargin(4)) ==0 ) then
+ param = list();
+ else
+ param =varargin(4); //Storing the 3rd Input Parameter in an intermediate list named 'param'
+ end
+
+ options = list("MaxIter",[3000],"CpuTime",[600],"TolX", [1e-4]);
+
+ //To check the user entry for options and storing it
+ for i = 1:(size(param))/2
+ select param(2*i-1)
+ case "MaxIter" then
+ options(2*i) = param(2*i);
+ case "CpuTime" then
+ options(2*i) = param(2*i);
+ case "TolX" then
+ options(2*i) = param(2*i);
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fminbnd", param(2*i-1));
+ error(errmsg)
+ end
+ end
+
+
+ //Defining a function to calculate Gradient or Hessian in an error deductable form.
+ function [y,check]=gradhess(x,t)
+ if t==1 then
+ if(execstr('y=numderivative(fun,x)','errcatch')==10000)
+ y=zeros(s(1),1);
+ check=1;
+ else
+ y=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=zeros(s(1),1);
+ check=1;
+ else
+ check=0;
+ end
+ end
+ else
+ if(execstr('[grad,y]=numderivative(fun,x)','errcatch')==10000)
+ y=zeros(s(1),1);
+ check=1;
+ else
+ [grad,y]=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=zeros(s(1),s(1));
+ check=1;
+ else
+ check=0;
+ end
+ end
+ end
+ endfunction
+
+ //Calling the Ipopt function for solving the above problem
+ [xopt,fopt,status,iter,cpu,obj_eval,dual,zl,zu] = solveminbndp(f,gradhess,x1,x2,options);
+
+ //Calculating the values for the output
+ xopt = xopt';
+ exitflag = status;
+ output = struct("Iterations", [],"Cpu_Time",[],"Objective_Evaluation",[],"Dual_Infeasibility",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ output.Objective_Evaluation = obj_eval;
+ output.Dual_Infeasibility = dual;
+ lambda = struct("lower", zl,"upper",zu);
+
+ //In the cases of the problem not being solved, return NULL to the output matrices
+ if( status~=0 & status~=1 & status~=2 & status~=3 & status~=4 & status~=7 ) then
+ xopt=[]
+ fopt=[]
+ output = struct("Iterations", [],"Cpu_Time",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ lambda = struct("lower",[],"upper",[]);
+ end
+
+ //To print output message
+ select status
+
+ case 0 then
+ printf("\nOptimal Solution Found.\n");
+ case 1 then
+ printf("\nMaximum Number of Iterations Exceeded. Output may not be optimal.\n");
+ case 2 then
+ printf("\nMaximum CPU Time exceeded. Output may not be optimal.\n");
+ case 3 then
+ printf("\nStop at Tiny Step\n");
+ case 4 then
+ printf("\nSolved To Acceptable Level\n");
+ case 5 then
+ printf("\nConverged to a point of local infeasibility.\n");
+ case 6 then
+ printf("\nStopping optimization at current point as requested by user.\n");
+ case 7 then
+ printf("\nFeasible point for square problem found.\n");
+ case 8 then
+ printf("\nIterates diverging; problem might be unbounded.\n");
+ case 9 then
+ printf("\nRestoration Failed!\n");
+ case 10 then
+ printf("\nError in step computation (regularization becomes too large?)!\n");
+ case 12 then
+ printf("\nProblem has too few degrees of freedom.\n");
+ case 13 then
+ printf("\nInvalid option thrown back by Ipopt\n");
+ case 14 then
+ printf("\nNot enough memory.\n");
+ case 15 then
+ printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n");
+ else
+ printf("\nInvalid status returned. Notify the Toolbox authors\n");
+ break;
+ end
+
+
+endfunction
diff --git a/macros/fmincon.bin b/macros/fmincon.bin
new file mode 100644
index 0000000..3ea45b3
--- /dev/null
+++ b/macros/fmincon.bin
Binary files differ
diff --git a/macros/fmincon.sci b/macros/fmincon.sci
new file mode 100644
index 0000000..2630683
--- /dev/null
+++ b/macros/fmincon.sci
@@ -0,0 +1,928 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// 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
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+function [xopt,fopt,exitflag,output,lambda,gradient,hessian] = fmincon (varargin)
+ // Solves a multi-variable constrainted optimization problem
+ //
+ // Calling Sequence
+ // xopt = fmincon(f,x0,A,b)
+ // xopt = fmincon(f,x0,A,b,Aeq,beq)
+ // xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub)
+ // xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc)
+ // xopt = fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ // [xopt,fopt] = fmincon(.....)
+ // [xopt,fopt,exitflag]= fmincon(.....)
+ // [xopt,fopt,exitflag,output]= fmincon(.....)
+ // [xopt,fopt,exitflag,output,lambda]=fmincon(.....)
+ // [xopt,fopt,exitflag,output,lambda,gradient]=fmincon(.....)
+ // [xopt,fopt,exitflag,output,lambda,gradient,hessian]=fmincon(.....)
+ //
+ // Parameters
+ // f : a function, representing the objective function of the problem
+ // x0 : a vector of doubles, containing the starting values of variables of size (1 X n) or (n X 1) where 'n' is the number of Variables
+ // A : a matrix of doubles, containing the coefficients of linear inequality constraints of size (m X n) where 'm' is the number of linear inequality constraints
+ // b : a vector of doubles, related to 'A' and containing the the Right hand side equation of the linear inequality constraints of size (m X 1)
+ // Aeq : a matrix of doubles, containing the coefficients of linear equality constraints of size (m1 X n) where 'm1' is the number of linear equality constraints
+ // beq : a vector of doubles, related to 'Aeq' and containing the the Right hand side equation of the linear equality constraints of size (m1 X 1)
+ // lb : a vector of doubles, containing the lower bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables
+ // ub : a vector of doubles, containing the upper bounds of the variables of size (1 X n) or (n X 1) where 'n' is the number of Variables
+ // nlc : a function, representing the Non-linear Constraints functions(both Equality and Inequality) of the problem. It is declared in such a way that non-linear inequality constraints are defined first as a single row vector (c), followed by non-linear equality constraints as another single row vector (ceq). Refer Example for definition of Constraint function.
+ // options : a list, containing the option for user to specify. See below for details.
+ // xopt : a vector of doubles, cointating the computed solution of the optimization problem
+ // fopt : a scalar of double, containing the the function value at x
+ // exitflag : a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
+ // output : a structure, containing the information about the optimization. See below for details.
+ // lambda : a structure, containing the Lagrange multipliers of lower bound, upper bound and constraints at the optimized point. See below for details.
+ // gradient : a vector of doubles, containing the Objective's gradient of the solution.
+ // hessian : a matrix of doubles, containing the Lagrangian's hessian of the solution.
+ //
+ // Description
+ // Search the minimum of a constrained optimization problem specified by :
+ // Find the minimum of f(x) such that
+ //
+ // <latex>
+ // \begin{eqnarray}
+ // &\mbox{min}_{x}
+ // & f(x) \\
+ // & \text{subject to} & A*x \leq b \\
+ // & & Aeq*x \ = beq\\
+ // & & c(x) \leq 0\\
+ // & & ceq(x) \ = 0\\
+ // & & lb \leq x \leq ub \\
+ // \end{eqnarray}
+ // </latex>
+ //
+ // The routine calls Ipopt for solving the Constrained Optimization problem, Ipopt is a library written in C++.
+ //
+ // The options allows the user to set various parameters of the Optimization problem.
+ // It should be defined as type "list" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "Hessian", ---, "GradCon", ---);</listitem>
+ // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+ // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+ // <listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+ // <listitem>Hessian : a function, representing the hessian function of the Lagrange in Symmetric Matrix Form with Input parameters x, Objective factor and Lambda. Refer Example for definition of Lagrangian Hessian function.</listitem>
+ // <listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 & m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+ // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+ // </itemizedlist>
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+ // <listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+ // <listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.Iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+ // <listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+ // <listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+ // </itemizedlist>
+ //
+ // The lambda data structure contains the Lagrange multipliers at the end
+ // of optimization. In the current version the values are returned only when the the solution is optimal.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+ // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+ // <listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+ // <listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+ // <listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+ // <listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // //Find x in R^2 such that it minimizes:
+ // //f(x)= -x1 -x2/3
+ // //x0=[0,0]
+ // //constraint-1 (c1): x1 + x2 <= 2
+ // //constraint-2 (c2): x1 + x2/4 <= 1
+ // //constraint-3 (c3): x1 - x2 <= 2
+ // //constraint-4 (c4): -x1/4 - x2 <= 1
+ // //constraint-5 (c5): -x1 - x2 <= -1
+ // //constraint-6 (c6): -x1 + x2 <= 2
+ // //constraint-7 (c7): x1 + x2 = 2
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=-x(1)-x(2)/3;
+ // endfunction
+ // //Starting point, linear constraints and variable bounds
+ // x0=[0 , 0];
+ // A=[1,1 ; 1,1/4 ; 1,-1 ; -1/4,-1 ; -1,-1 ; -1,1];
+ // b=[2;1;2;1;-1;2];
+ // Aeq=[1,1];
+ // beq=[2];
+ // lb=[];
+ // ub=[];
+ // nlc=[];
+ // //Gradient of objective function
+ // function y= fGrad(x)
+ // y= [-1,-1/3];
+ // endfunction
+ // //Hessian of lagrangian
+ // function y= lHess(x,obj,lambda)
+ // y= obj*[0,0;0,0]
+ // endfunction
+ // //Options
+ // options=list("GradObj", fGrad, "Hessian", lHess);
+ // //Calling Ipopt
+ // [x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Find x in R^3 such that it minimizes:
+ // //f(x)= x1*x2 + x2*x3
+ // //x0=[0.1 , 0.1 , 0.1]
+ // //constraint-1 (c1): x1^2 - x2^2 + x3^2 <= 2
+ // //constraint-2 (c2): x1^2 + x2^2 + x3^2 <= 10
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=x(1)*x(2)+x(2)*x(3);
+ // endfunction
+ // //Starting point, linear constraints and variable bounds
+ // x0=[0.1 , 0.1 , 0.1];
+ // A=[];
+ // b=[];
+ // Aeq=[];
+ // beq=[];
+ // lb=[];
+ // ub=[];
+ // //Nonlinear constraints
+ // function [c,ceq]=nlc(x)
+ // c = [x(1)^2 - x(2)^2 + x(3)^2 - 2 , x(1)^2 + x(2)^2 + x(3)^2 - 10];
+ // ceq = [];
+ // endfunction
+ // //Gradient of objective function
+ // function y= fGrad(x)
+ // y= [x(2),x(1)+x(3),x(2)];
+ // endfunction
+ // //Hessian of the Lagrange Function
+ // function y= lHess(x,obj,lambda)
+ // y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,-2,0;0,0,2] + lambda(2)*[2,0,0;0,2,0;0,0,2]
+ // endfunction
+ // //Gradient of Non-Linear Constraints
+ // function [cg,ceqg] = cGrad(x)
+ // cg=[2*x(1) , -2*x(2) , 2*x(3) ; 2*x(1) , 2*x(2) , 2*x(3)];
+ // ceqg=[];
+ // endfunction
+ // //Options
+ // options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+ // //Calling Ipopt
+ // [x,fval,exitflag,output] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //The below problem is an unbounded problem:
+ // //Find x in R^3 such that it minimizes:
+ // //f(x)= -(x1^2 + x2^2 + x3^2)
+ // //x0=[0.1 , 0.1 , 0.1]
+ // // x1 <= 0
+ // // x2 <= 0
+ // // x3 <= 0
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=-(x(1)^2+x(2)^2+x(3)^2);
+ // endfunction
+ // //Starting point, linear constraints and variable bounds
+ // x0=[0.1 , 0.1 , 0.1];
+ // A=[];
+ // b=[];
+ // Aeq=[];
+ // beq=[];
+ // lb=[];
+ // ub=[0,0,0];
+ // //Options
+ // options=list("MaxIter", [1500], "CpuTime", [500]);
+ // //Calling Ipopt
+ // [x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,[],options)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //The below problem is an infeasible problem:
+ // //Find x in R^3 such that in minimizes:
+ // //f(x)=x1*x2 + x2*x3
+ // //x0=[1,1,1]
+ // //constraint-1 (c1): x1^2 <= 1
+ // //constraint-2 (c2): x1^2 + x2^2 <= 1
+ // //constraint-3 (c3): x3^2 <= 1
+ // //constraint-4 (c4): x1^3 = 0.5
+ // //constraint-5 (c5): x2^2 + x3^2 = 0.75
+ // // 0 <= x1 <=0.6
+ // // 0.2 <= x2 <= inf
+ // // -inf <= x3 <= 1
+ // //Objective function to be minimised
+ // function y=f(x)
+ // y=x(1)*x(2)+x(2)*x(3);
+ // endfunction
+ // //Starting point, linear constraints and variable bounds
+ // x0=[1,1,1];
+ // A=[];
+ // b=[];
+ // Aeq=[];
+ // beq=[];
+ // lb=[0 0.2,-%inf];
+ // ub=[0.6 %inf,1];
+ // //Nonlinear constraints
+ // function [c,ceq]=nlc(x)
+ // c=[x(1)^2-1,x(1)^2+x(2)^2-1,x(3)^2-1];
+ // ceq=[x(1)^3-0.5,x(2)^2+x(3)^2-0.75];
+ // endfunction
+ // //Gradient of objective function
+ // function y= fGrad(x)
+ // y= [x(2),x(1)+x(3),x(2)];
+ // endfunction
+ // //Hessian of the Lagrange Function
+ // function y= lHess(x,obj,lambda)
+ // y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,0,0;0,0,0] + lambda(2)*[2,0,0;0,2,0;0,0,0] +lambda(3)*[0,0,0;0,0,0;0,0,2] + lambda(4)*[6*x(1 ),0,0;0,0,0;0,0,0] + lambda(5)*[0,0,0;0,2,0;0,0,2];
+ // endfunction
+ // //Gradient of Non-Linear Constraints
+ // function [cg,ceqg] = cGrad(x)
+ // cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ // ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)];
+ // endfunction
+ // //Options
+ // options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+ // //Calling Ipopt
+ // [x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+ // Authors
+ // R.Vidyadhar , Vignesh Kannan
+
+
+ //To check the number of input and output arguments
+ [lhs , rhs] = argn();
+
+ //To check the number of arguments given by the user
+ if ( rhs<4 | rhs>13 ) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while it should be 4,6,8,9,10,11,12,13"), "fmincon", rhs);
+ error(errmsg)
+ end
+
+ if (rhs==5 | rhs==7) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while it should be 4,6,8,9,10,11,12,13"), "fmincon", rhs);
+ error(errmsg)
+ end
+
+ //Storing the Input Parameters
+ fun = varargin(1);
+ x0 = varargin(2);
+ A = varargin(3);
+ b = varargin(4);
+ Aeq = [];
+ beq = [];
+ lb = [];
+ ub = [];
+ nlc = [];
+
+ if (rhs>4) then
+ Aeq = varargin(5);
+ beq = varargin(6);
+ end
+
+ if (rhs>6) then
+ lb = varargin(7);
+ ub = varargin(8);
+ end
+
+ if (rhs>8) then
+ nlc = varargin(9);
+ end
+
+ //To check whether the 1st Input argument (f) is a function or not
+ if (type(f) ~= 13 & type(f) ~= 11) then
+ errmsg = msprintf(gettext("%s: Expected function for Objective (1st Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check whether the 2nd Input argument (x0) is a vector/scalar
+ if (type(x0) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Starting Point (2nd Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check and convert the 2nd Input argument (x0) to a row vector
+ if((size(x0,1)~=1) & (size(x0,2)~=1)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector or Column Vector for x0 (Starting Point) or Starting Point cannot be Empty"), "fmincon");
+ error(errmsg);
+ end
+
+ if(size(x0,2)==1) then
+ x0=x0'; //Converting x0 to a row vector, if it is a column vector
+ else
+ x0=x0; //Retaining the same, if it is already a row vector
+ end
+ s=size(x0);
+
+ //To check the match between fun (1st Parameter) and x0 (2nd Parameter)
+ if(execstr('init=fun(x0)','errcatch')==21) then
+ errmsg = msprintf(gettext("%s: Objective function and x0 did not match"), "fmincon");
+ error(errmsg);
+ end
+
+ //Converting the User defined Objective function into Required form (Error Detectable)
+ function [y,check] = f(x)
+ if(execstr('y=fun(x)','errcatch')==32 | execstr('y=fun(x)','errcatch')==27)
+ y=0;
+ check=1;
+ else
+ y=fun(x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+
+ //To check whether the 3rd Input argument (A) is a Matrix/Vector
+ if (type(A) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Matrix/Vector for Constraint Matrix A (3rd parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for correct size of A(3rd paramter)
+ if(size(A,2)~=s(2) & size(A,2)~=0) then
+ errmsg = msprintf(gettext("%s: Expected Matrix of size (No of linear inequality constraints X No of Variables) or an Empty Matrix for Linear Inequality Constraint coefficient Matrix A"), "fmincon");
+ error(errmsg);
+ end
+
+ s1=size(A);
+
+ //To check whether the 4th Input argument (b) is a vector/scalar
+ if (type(b) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for b (4th Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for the correct size of b (4th paramter) and convert it into a column vector which is required for Ipopt
+ if(s1(2)==0) then
+ if(size(b,2)~=0) then
+ errmsg = msprintf(gettext("%s: As Linear Inequality Constraint coefficient Matrix A (3rd parameter) is empty, b (4th Parameter) should also be empty"), "fmincon");
+ error(errmsg);
+ end
+ else
+ if((size(b,1)~=1) & (size(b,2)~=1)) then
+ errmsg = msprintf(gettext("%s: Expected Non empty Row/Column Vector for b (4th Parameter) for your Inputs "), "fmincon");
+ error(errmsg);
+ elseif(size(b,1)~=s1(1) & size(b,2)==1) then
+ errmsg = msprintf(gettext("%s: Expected Column Vector (number of linear inequality constraints X 1) for b (4th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(b,1)==s1(1) & size(b,2)==1) then
+ b=b;
+ elseif(size(b,1)==1 & size(b,2)~=s1(1)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector (1 X number of linear inequality constraints) for b (4th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(b,1)==1 & size(b,2)==s1(1)) then
+ b=b';
+ end
+ end
+
+ //To check whether the 5th Input argument (Aeq) is a matrix/vector
+ if (type(Aeq) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Matrix/Vector for Equality Constraint Matrix Aeq (5th Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for the correct size of Aeq (5th paramter)
+ if(size(Aeq,2)~=s(2) & size(Aeq,2)~=0) then
+ errmsg = msprintf(gettext("%s: Expected Matrix of size (No of linear equality constraints X No of Variables) or an Empty Matrix for Linear Equality Constraint coefficient Matrix Aeq"), "fmincon");
+ error(errmsg);
+ end
+
+ s2=size(Aeq);
+
+ //To check whether the 6th Input argument(beq) is a vector/scalar
+ if (type(beq) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for beq (6th Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for the correct size of beq(6th paramter) and convert it into a column vector which is required for Ipopt
+ if(s2(2)==0) then
+ if(size(beq,2)~=0) then
+ errmsg = msprintf(gettext("%s: As Linear Equality Constraint coefficient Matrix Aeq (5th parameter) is empty, beq (6th Parameter) should also be empty"), "fmincon");
+ error(errmsg);
+ end
+ else
+ if((size(beq,1)~=1) & (size(beq,2)~=1)) then
+ errmsg = msprintf(gettext("%s: Expected Non empty Row/Column Vector for beq (6th Parameter)"), "fmincon");
+ error(errmsg);
+ elseif(size(beq,1)~=s2(1) & size(beq,2)==1) then
+ errmsg = msprintf(gettext("%s: Expected Column Vector (number of linear equality constraints X 1) for beq (6th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(beq,1)==s2(1) & size(beq,2)==1) then
+ beq=beq;
+ elseif(size(beq,1)==1 & size(beq,2)~=s2(1)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector (1 X number of linear equality constraints) for beq (6th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(beq,1)==1 & size(beq,2)==s2(1)) then
+ beq=beq';
+ end
+ end
+
+
+ //To check whether the 7th Input argument (lb) is a vector/scalar
+ if (type(lb) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Lower Bound Vector (7th Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for the correct size and data of lb (7th paramter) and convert it into a column vector as required by Ipopt
+ if (size(lb,2)==0) then
+ lb = repmat(-%inf,1,s(2));
+ end
+
+ if (size(lb,1)~=1) & (size(lb,2)~=1) then
+ errmsg = msprintf(gettext("%s: Lower Bound (7th Parameter) should be a vector"), "fmincon");
+ error(errmsg);
+ elseif(size(lb,1)~=s(2) & size(lb,2)==1) then
+ errmsg = msprintf(gettext("%s: Expected Column Vector (number of Variables X 1) for lower bound (7th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(lb,1)==s(2) & size(lb,2)==1) then
+ lb=lb;
+ elseif(size(lb,1)==1 & size(lb,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector (1 X number of Variables) for lower bound (7th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(lb,1)==1 & size(lb,2)==s(2)) then
+ lb=lb';
+ end
+
+ //To check whether the 8th Input argument (ub) is a vector/scalar
+ if (type(ub) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Upper Bound Vector (8th Parameter)"), "fmincon");
+ error(errmsg);
+ end
+
+ //To check for the correct size and data of ub (8th paramter) and convert it into a column vector as required by Ipopt
+ if (size(ub,2)==0) then
+ ub = repmat(%inf,1,s(2));
+ end
+
+ if (size(ub,1)~=1)& (size(ub,2)~=1) then
+ errmsg = msprintf(gettext("%s: Upper Bound (8th Parameter) should be a vector"), "fmincon");
+ error(errmsg);
+ elseif(size(ub,1)~=s(2) & size(ub,2)==1) then
+ errmsg = msprintf(gettext("%s: Expected Column Vector (number of Variables X 1) for upper bound (8th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(ub,1)==s(2) & size(ub,2)==1) then
+ ub=ub;
+ elseif(size(ub,1)==1 & size(ub,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector (1 X number of Variables) for upper bound (8th Parameter) "), "fmincon");
+ error(errmsg);
+ elseif(size(ub,1)==1 & size(ub,2)==s(2)) then
+ ub=ub';
+ end
+
+ //To check the contents of lb & ub (7th & 8th Parameter)
+ for i = 1:s(2)
+ if (lb(i) == %inf) then
+ errmsg = msprintf(gettext("%s: Value of Lower Bound can not be infinity"), "fmincon");
+ error(errmsg);
+ end
+
+ if (ub(i) == -%inf) then
+ errmsg = msprintf(gettext("%s: Value of Upper Bound can not be negative infinity"), "fmincon");
+ error(errmsg);
+ end
+
+ if(ub(i)-lb(i)<=1e-6) then
+ errmsg = msprintf(gettext("%s: Difference between Upper Bound and Lower bound should be atleast > 10^6 for variable number= %d "), "fmincon", i);
+ error(errmsg)
+ end
+ end
+
+ //To check whether the 10th Input argument (nlc) is a function or an empty matrix
+ if (type(nlc) == 1 & size(nlc,2)==0 ) then
+ addnlc=[];
+ addnlc1=[];
+ no_nlc=0;
+ no_nlic=0;
+ no_nlec=0;
+ elseif (type(nlc) == 13 | type(nlc) == 11) then
+
+ if(execstr('[sample_c,sample_ceq] = nlc(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Non-Linear Constraint function(9th Parameter) and x0(2nd Parameter) did not match"), "fmincon");
+ error(errmsg);
+ end
+ [sample_c,sample_ceq] = nlc(x0);
+
+ if (size(sample_c,1)~=1 & size(sample_c,1)~=0) then
+ errmsg = msprintf(gettext("%s: Definition of c in Non-Linear Constraint function(9th Parameter) should be in the form of Row Vector or Empty Vector"), "fmincon");
+ error(errmsg)
+ end
+
+ if (size(sample_ceq,1)~=1 & size(sample_ceq,1)~=0) then
+ errmsg = msprintf(gettext("%s: Definition of ceq in Non-Linear Constraint function(9th Parameter) should be in the form of Row Vector or Empty Vector"), "fmincon");
+ error(errmsg)
+ end
+
+ no_nlic = size(sample_c,2);
+ no_nlec = size(sample_ceq,2);
+ no_nlc = no_nlic + no_nlec;
+
+ //Constructing a single output variable function for nlc
+ function y = addnlc(x)
+ [c,ceq] = nlc(x);
+ y = [c';ceq'];
+ endfunction
+
+ //To check the addnlc function
+ if(execstr('sample_allcon = addnlc(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Non-Linear Constraint function(9th Parameter) and x0(2nd Parameter) did not match"), "fmincon");
+ error(errmsg);
+ end
+ sample_allcon = addnlc(x0);
+
+ if (size(sample_allcon,1)==0 & size(sample_allcon,2)==0) then
+
+ elseif (size(sample_allcon,1)~=no_nlc | size(sample_allcon,2)~=1) then
+ errmsg = msprintf(gettext("%s: Please check the Non-Linear Constraint function (9th Parameter) function"), "fmincon");
+ error(errmsg)
+ end
+
+ //Constructing a nlc function with error deduction
+ function [y,check] = addnlc1(x)
+ if(execstr('y = addnlc(x)','errcatch')==32 | execstr('y = addnlc(x)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y = addnlc(x);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+
+ else
+ errmsg = msprintf(gettext("%s: Non Linear Constraint (9th Parameter) should be a function or an Empty Matrix"), "fmincon");
+ error(errmsg)
+ end
+
+ //To check whether options has been entered by the user
+ if ( rhs<10 ) then
+ param = list();
+ else
+ param =varargin(10); //Storing the 3rd Input Parameter in an intermediate list named 'param'
+ end
+
+ //If options has been entered, then check its type for 'list'
+ if (type(param) ~= 15) then
+ errmsg = msprintf(gettext("%s: Options (10th parameter) should be a list"), "fmincon");
+ error(errmsg);
+ end
+
+ //If options has been entered, then check whether an even number of entires has been entered
+ if (modulo(size(param),2)) then
+ errmsg = msprintf(gettext("%s: Size of Options (list) should be even"), "fmincon");
+ error(errmsg);
+ end
+
+
+ //Defining a function to calculate Gradient or Hessian if the respective user entry is OFF
+ function [y,check] = gradhess(x,t)
+ if t==1 then //To return Gradient
+ if(execstr('y=numderivative(fun,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ y=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ elseif t==2 then //To return Hessian
+ if(execstr('[grad,y]=numderivative(fun,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ [grad,y]=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ elseif t==3 then //To return Gradient
+ if(execstr('y=numderivative(addnlc,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ y=numderivative(addnlc,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ elseif t==4 then //To return Hessian
+ if(execstr('[grad,y]=numderivative(addnlc,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ [grad,y]=numderivative(addnlc,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ end
+ endfunction
+
+ //To set default values for options, if user doesn't enter options
+ options = list("MaxIter", [3000], "CpuTime", [600]);
+
+ //Flags to check whether Gradient is "ON"/"OFF" and Hessian is "ON"/"OFF"
+ flag1=0;
+ flag2=0;
+ flag3=0;
+
+ //Function for Gradient and Hessian
+ fGrad=[];
+ fGrad1=[];
+ lHess=[];
+ lHess1=[];
+ cGrad=[];
+ addcGrad=[];
+ addcGrad1=[];
+
+ //To check the user entry for options and storing it
+ for i = 1:(size(param))/2
+ select param(2*i-1)
+ case "MaxIter" then
+ options(2*i) = param(2*i); //Setting the maximum number of iterations as per user entry
+ case "CpuTime" then
+ options(2*i) = param(2*i); //Setting the maximum CPU time as per user entry
+ case "GradObj" then
+ flag1=1;
+ fGrad=param(2*i);
+ case "Hessian" then
+ flag2=1;
+ lHess=param(2*i);
+ case "GradCon" then
+ flag3=1;
+ cGrad=param(2*i);
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fminbnd", param(2*i-1));
+ error(errmsg);
+ end
+ end
+
+ //To check for correct input of Gradient and Hessian functions from the user
+ if (flag1==1) then
+ if (type(fGrad) ~= 11 & type(fGrad) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Objective"), "fmincon");
+ error(errmsg);
+ end
+
+ if(execstr('sample_fGrad=fGrad(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Gradient function of Objective and x0 did not match "), "fmincon");
+ error(errmsg);
+ end
+
+ sample_fGrad=fGrad(x0);
+
+ if (size(sample_fGrad,1)==s(2) & size(sample_fGrad,2)==1) then
+ elseif (size(sample_fGrad,1)==1 & size(sample_fGrad,2)==s(2)) then
+ elseif (size(sample_fGrad,1)~=1 & size(sample_fGrad,2)~=1) then
+ errmsg = msprintf(gettext("%s: Wrong Input for Objective Gradient function(10th Parameter)---->Vector function is Expected"), "fmincon");
+ error(errmsg);
+ end
+
+ function [y,check] = fGrad1(x)
+ if(execstr('y=fGrad(x)','errcatch')==32 | execstr('y=fGrad(x)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y=fGrad(x);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+
+ end
+ if (flag2==1) then
+ if (type(lHess) ~= 11 & type(lHess) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Hessian of Objective"), "fmincon");
+ error(errmsg);
+ end
+ if(execstr('sample_lHess=lHess(x0,1,1:no_nlc)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Hessian function of Objective and x0 did not match "), "fmincon");
+ error(errmsg);
+ end
+ sample_lHess=lHess(x0,1,1:no_nlc);
+ if(size(sample_lHess,1)~=s(2) | size(sample_lHess,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Wrong Input for Objective Hessian function(10th Parameter)---->Symmetric Matrix function is Expected "), "fmincon");
+ error(errmsg);
+ end
+
+ function [y,check] = lHess1(x,obj,lambda)
+ if(execstr('y=lHess(x,obj,lambda)','errcatch')==32 | execstr('y=lHess(x,obj,lambda)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y=lHess(x,obj,lambda);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+
+ end
+ if (flag3==1) then
+ if (type(cGrad) ~= 11 & type(cGrad) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Constraint function"), "fmincon");
+ error(errmsg);
+ end
+
+ if(execstr('[sample_cGrad,sample_ceqg]=cGrad(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Gradient function of Constraint and x0 did not match "), "fmincon");
+ error(errmsg);
+ end
+ [sample_cGrad,sample_ceqg]=cGrad(x0);
+
+ if (size(sample_cGrad,2)==0) then
+ elseif (size(sample_cGrad,1)~=no_nlic | size(sample_cGrad,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Definition of (cGrad) in Non-Linear Constraint function(10th Parameter) should be in the form of (m X n) or Empty Matrix where m is number of Non- linear inequality constraints and n is number of Variables"), "fmincon");
+ error(errmsg);
+ end
+
+ if (size(sample_ceqg,2)==0) then
+ elseif (size(sample_ceqg,1)~=no_nlec | size(sample_ceqg,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Definition of (ceqg) in Non-Linear Constraint function(10th Parameter) should be in the form of (m X n) or Empty Matrix where m is number of Non- linear equality constraints and n is number of Variables"), "fmincon");
+ error(errmsg);
+ end
+
+ function y = addcGrad(x)
+ [sample_cGrad,sample_ceqg] = cGrad(x);
+ y = [sample_cGrad;sample_ceqg];
+ endfunction
+
+ sample_addcGrad=addcGrad(x0);
+ if(size(sample_addcGrad,1)~=no_nlc | size(sample_addcGrad,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Wrong Input for Constraint Gradient function(10th Parameter) (Refer Help)"), "fmincon");
+ error(errmsg);
+ end
+
+ function [y,check] = addcGrad1(x)
+ if(execstr('y=addcGrad(x)','errcatch')==32 | execstr('y=addcGrad(x)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y=addcGrad(x);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+ end
+
+ //To Convert the Gradient and Hessian into Error Debugable form
+
+
+ //Dummy variable which is used by Ipopt
+ empty=0;
+
+ //Calling the Ipopt function for solving the above problem
+ [xopt,fopt,status,iter,cpu,obj_eval,dual,lambda1,zl,zu,gradient,hessian1] = solveminconp (f,gradhess,A,b,Aeq,beq,lb,ub,no_nlc,no_nlic,addnlc1,flag1,fGrad1,flag2,lHess1,flag3,addcGrad1,x0,options,empty)
+
+ //Calculating the values for the output
+ xopt = xopt';
+ exitflag = status;
+ output = struct("Iterations", [],"Cpu_Time",[],"Objective_Evaluation",[],"Dual_Infeasibility",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ output.Objective_Evaluation = obj_eval;
+ output.Dual_Infeasibility = dual;
+ lambda = struct("lower", zl,"upper",zu,"ineqlin",[],"eqlin",[],"ineqnonlin",[],"eqnonlin",[]);
+
+ if (no_nlic ~= 0) then
+ for i = 1:no_nlic
+ lambda.ineqnonlin (i) = lambda1(i)
+ end
+ lambda.ineqnonlin = lambda.ineqnonlin'
+ end
+
+ if (no_nlec ~= 0) then
+ j=1;
+ for i = no_nlic+1 : no_nlc
+ lambda.eqnonlin (j) = lambda1(i)
+ j= j+1;
+ end
+ lambda.eqnonlin = lambda.eqnonlin'
+ end
+
+ if (Aeq ~=[]) then
+ j=1;
+ for i = no_nlc+1 : no_nlc + size(Aeq,1)
+ lambda.eqlin (j) = lambda1(i)
+ j= j+1;
+ end
+ lambda.eqlin = lambda.eqlin'
+ end
+
+ if (A ~=[]) then
+ j=1;
+ for i = no_nlc+ size(Aeq,1)+ 1 : no_nlc + size(Aeq,1) + size(A,1)
+ lambda.ineqlin (j) = lambda1(i)
+ j= j+1;
+ end
+ lambda.ineqlin = lambda.ineqlin'
+ end
+
+ //Converting hessian of order (1 x (numberOfVariables)^2) received from Ipopt to order (numberOfVariables x numberOfVariables)
+ s1=size(gradient)
+ for i =1:s1(2)
+ for j =1:s1(2)
+ hessian(i,j)= hessian1(j+((i-1)*s1(2)))
+ end
+ end
+
+ //In the cases of the problem not being solved, return NULL to the output matrices
+ if( status~=0 & status~=1 & status~=2 & status~=3 & status~=4 & status~=7 ) then
+ xopt=[];
+ fopt=[];
+ output = struct("Iterations", [],"Cpu_Time",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ lambda = struct("lower",[],"upper",[],"ineqlin",[],"eqlin",[],"ineqnonlin",[],"eqnonlin",[]);
+ gradient=[];
+ hessian=[];
+ end
+
+
+ //To print output message
+ select status
+
+ case 0 then
+ printf("\nOptimal Solution Found.\n");
+ case 1 then
+ printf("\nMaximum Number of Iterations Exceeded. Output may not be optimal.\n");
+ case 2 then
+ printf("\nMaximum CPU Time exceeded. Output may not be optimal.\n");
+ case 3 then
+ printf("\nStop at Tiny Step\n");
+ case 4 then
+ printf("\nSolved To Acceptable Level\n");
+ case 5 then
+ printf("\nConverged to a point of local infeasibility.\n");
+ case 6 then
+ printf("\nStopping optimization at current point as requested by user.\n");
+ case 7 then
+ printf("\nFeasible point for square problem found.\n");
+ case 8 then
+ printf("\nIterates diverging; problem might be unbounded.\n");
+ case 9 then
+ printf("\nRestoration Failed!\n");
+ case 10 then
+ printf("\nError in step computation (regularization becomes too large?)!\n");
+ case 11 then
+ printf("\nProblem has too few degrees of freedom.\n");
+ case 12 then
+ printf("\nInvalid option thrown back by Ipopt\n");
+ case 13 then
+ printf("\nNot enough memory.\n");
+ case 15 then
+ printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n");
+ else
+ printf("\nInvalid status returned. Notify the Toolbox authors\n");
+ break;
+ end
+
+
+endfunction
diff --git a/macros/fminimax.bin b/macros/fminimax.bin
new file mode 100644
index 0000000..c40fcce
--- /dev/null
+++ b/macros/fminimax.bin
Binary files differ
diff --git a/macros/fminimax.sci b/macros/fminimax.sci
new file mode 100644
index 0000000..5084475
--- /dev/null
+++ b/macros/fminimax.sci
@@ -0,0 +1,511 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Authors: Animesh Baranawal
+// Organization: FOSSEE, IIT Bombay
+// Email: animeshbaranawal@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
+
+function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin)
+ // Solves minimax constraint problem
+ //
+ // Calling Sequence
+ // x = fminimax(fun,x0)
+ // x = fminimax(fun,x0,A,b)
+ // x = fminimax(fun,x0,A,b,Aeq,beq)
+ // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub)
+ // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun)
+ // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun,options)
+ // [x, fval] = fmincon(.....)
+ // [x, fval, maxfval]= fmincon(.....)
+ // [x, fval, maxfval, exitflag]= fmincon(.....)
+ // [x, fval, maxfval, exitflag, output]= fmincon(.....)
+ // [x, fval, maxfval, exitflag, output, lambda]= fmincon(.....)
+ //
+ // Parameters
+ // fun: The function to be minimized. fun is a function that accepts a vector x and returns a vector F, the objective functions evaluated at x.
+ // x0: a nx1 or 1xn matrix of doubles, where n is the number of variables, the initial guess for the optimization algorithm
+ // A: a nil x n matrix of doubles, where n is the number of variables and nil is the number of linear inequalities. If A==[] and b==[], it is assumed that there is no linear inequality constraints. If (A==[] & b<>[]), fminimax generates an error (the same happens if (A<>[] & b==[]))
+ // b: a nil x 1 matrix of doubles, where nil is the number of linear inequalities
+ // Aeq: a nel x n matrix of doubles, where n is the number of variables and nel is the number of linear equalities. If Aeq==[] and beq==[], it is assumed that there is no linear equality constraints. If (Aeq==[] & beq<>[]), fminimax generates an error (the same happens if (Aeq<>[] & beq==[]))
+ // beq: a nel x 1 matrix of doubles, where nel is the number of linear equalities
+ // lb: a nx1 or 1xn matrix of doubles, where n is the number of variables. The lower bound for x. If lb==[], then the lower bound is automatically set to -inf
+ // ub: a nx1 or 1xn matrix of doubles, where n is the number of variables. The upper bound for x. If ub==[], then the upper bound is automatically set to +inf
+ // nonlinfun: function that computes the nonlinear inequality constraints c(x) <= 0 and nonlinear equality constraints ceq(x) = 0.
+ // x: a nx1 matrix of doubles, the computed solution of the optimization problem
+ // fval: a vector of doubles, the value of fun at x
+ // maxfval: a 1x1 matrix of doubles, the maximum value in vector fval
+ // exitflag: a 1x1 matrix of floating point integers, the exit status
+ // output: a struct, the details of the optimization process
+ // lambda: a struct, the Lagrange multipliers at optimum
+ // options: a list, containing the option for user to specify. See below for details.
+ //
+ // Description
+ // fminimax minimizes the worst-case (largest) value of a set of multivariable functions, starting at an initial estimate. This is generally referred to as the minimax problem.
+ //
+ // <latex>
+ // \min_{x} \max_{i} F_{i}(x)\: \textrm{such that} \:\begin{cases}
+ // & c(x) \leq 0 \\
+ // & ceq(x) = 0 \\
+ // & A.x \leq b \\
+ // & Aeq.x = beq \\
+ // & minmaxLb \leq x \leq minmaxUb
+ // \end{cases}
+ // </latex>
+ //
+ // Currently, fminimax calls fmincon which uses the ip-opt algorithm.
+ //
+ // max-min problems can also be solved with fminimax, using the identity
+ //
+ // <latex>
+ // \max_{x} \min_{i} F_{i}(x) = -\min_{x} \max_{i} \left( -F_{i}(x) \right)
+ // </latex>
+ //
+ // The options allows the user to set various parameters of the Optimization problem.
+ // It should be defined as type "list" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "GradObj", ---, "GradCon", ---);</listitem>
+ // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+ // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+ // <listitem>GradObj : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+ // <listitem>GradCon : a function, representing the gradient of the Non-Linear Constraints (both Equality and Inequality) of the problem. It is declared in such a way that gradient of non-linear inequality constraints are defined first as a separate Matrix (cg of size m2 X n or as an empty), followed by gradient of non-linear equality constraints as a separate Matrix (ceqg of size m2 X n or as an empty) where m2 & m3 are number of non-linear inequality and equality constraints respectively.</listitem>
+ // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+ // </itemizedlist>
+ //
+ // The objective function must have header :
+ // <programlisting>
+ // F = fun(x)
+ // </programlisting>
+ // where x is a n x 1 matrix of doubles and F is a m x 1 matrix of doubles where m is the total number of objective functions inside F.
+ // On input, the variable x contains the current point and, on output, the variable F must contain the objective function values.
+ //
+ // 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.
+ //
+ // If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ //
+ // Furthermore, we must enable the "GradObj" option with the statement :
+ // <programlisting>
+ // minimaxOptions = list("GradObj",fGrad);
+ // </programlisting>
+ // This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function. Note that, fGrad should be mentioned in the form of N x n where n is the number of variables, N is the number of functions in objective function.
+ //
+ // The constraint function must have header :
+ // <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).
+ // 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.
+ //
+ // If we can provide exact gradients, we should do so since it improves the convergence speed of the optimization algorithm.
+ //
+ // Furthermore, we must enable the "GradCon" option with the statement :
+ // <programlisting>
+ // minimaxOptions = list("GradCon",confunGrad);
+ // </programlisting>
+ // This will let fminimax know that the exact gradient of the objective function is known, so that it can change the calling sequence to the objective function.
+ //
+ // The constraint derivative function must have header :
+ // <programlisting>
+ // [dc,dceq] = confungrad(x)
+ // </programlisting>
+ // where dc is a nni x n matrix of doubles and dceq is a nne x n matrix of doubles.
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=2 : Maximum amount of CPU Time exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+ // <listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+ // <listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.Iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+ // <listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+ // <listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+ // </itemizedlist>
+ //
+ // The lambda data structure contains the Lagrange multipliers at the end
+ // of optimization. In the current version the values are returned only when the the solution is optimal.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+ // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+ // <listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+ // <listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+ // <listitem>lambda.eqnonlin: The Lagrange multipliers for the non-linear equality constraints.</listitem>
+ // <listitem>lambda.ineqnonlin: The Lagrange multipliers for the non-linear inequality constraints.</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // // A basic case :
+ // // we provide only the objective function and the nonlinear constraint
+ // // function
+ // function f = myfun(x)
+ // f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304; //Objectives
+ // f(2)= -x(1)^2 - 3*x(2)^2;
+ // f(3)= x(1) + 3*x(2) -18;
+ // 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]
+ // maxfopt = 0
+ // // Run fminimax
+ // [xopt,fopt,maxfval,exitflag,output,lambda] = fminimax(myfun, x0)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // // A case where we provide the gradient of the objective
+ // // functions and the Jacobian matrix of the constraints.
+ // // The objective function and its gradient
+ // function f = myfun(x)
+ // f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304;
+ // f(2)= -x(1)^2 - 3*x(2)^2;
+ // f(3)= x(1) + 3*x(2) -18;
+ // 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)
+ // // Inequality constraints
+ // c = [1.5 + x(1)*x(2) - x(1) - x(2), -x(1)*x(2) - 10]
+ // // No nonlinear equality constraints
+ // ceq=[]
+ // endfunction
+ // // Defining gradient of confungrad
+ // function [DC,DCeq] = cgrad(x)
+ // // DC(:,i) = gradient of the i-th constraint
+ // // DC = [
+ // // Dc1/Dx1 Dc1/Dx2
+ // // Dc2/Dx1 Dc2/Dx2
+ // // ]
+ // DC= [
+ // x(2)-1, -x(2)
+ // x(1)-1, -x(1)
+ // ]'
+ // 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]
+ // maxfopt = 6.73443
+ // // Run fminimax
+ // [xopt,fopt,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)
+
+ // Proper initialisation of objective function
+ minmaxObjfun = varargin(1)
+ fminimaxChecktype("fminimax", minmaxObjfun, "minmaxObjfun", 1, "function")
+
+ // Proper initialisation of starting point
+ minmaxStartpoint = varargin(2)
+ fminimaxChecktype("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, "constant")
+
+ minmaxNumvar = size(minmaxStartpoint,"*")
+ fminimaxCheckvector("fminimax", minmaxStartpoint, "minmaxStartpoint", 2, minmaxNumvar)
+ minmaxStartpoint = minmaxStartpoint(:)
+
+ // Proper initialisation of A and b
+ if(minmaxRhs < 3) then // if A and b are not provided, declare as empty
+ minmaxA = []
+ minmaxB = []
+ else
+ minmaxA = varargin(3)
+ minmaxB = varargin(4)
+ end
+
+ fminimaxChecktype("fminimax", minmaxA, "A", 3, "constant")
+ fminimaxChecktype("fminimax", minmaxB, "b", 4, "constant")
+
+ // Check if A and b of proper dimensions
+ if(minmaxA <> [] & minmaxB == []) then
+ errmsg = msprintf(gettext("%s: Incompatible input arguments #%d and #%d: matrix A is empty, but the column vector b is not empty"), "fminimax", 3, 4)
+ error(errmsg)
+ end
+
+ if(minmaxA == [] & minmaxB <> []) then
+ errmsg = msprintf(gettext("%s: Incompatible input arguments #%d and #%d: matrix A is not empty, but the column vector b is empty"), "fminimax", 3, 4)
+ error(errmsg)
+ end
+
+ minmaxNumrowA = size(minmaxA,"r")
+ if(minmaxA <> []) then
+ fminimaxCheckdims("fminimax", minmaxA, "A", 3, [minmaxNumrowA minmaxNumvar])
+ fminimaxCheckvector("fminimax", minmaxB, "b", 4, minmaxNumrowA)
+ minmaxB = minmaxB(:)
+ end
+
+ // Proper initialisation of Aeq and beq
+ if(minmaxRhs < 5) then // if Aeq and beq are not provided, declare as empty
+ minmaxAeq = []
+ minmaxBeq = []
+ else
+ minmaxAeq = varargin(5)
+ minmaxBeq = varargin(6)
+ end
+
+ fminimaxChecktype("fminimax", minmaxAeq, "Aeq", 5, "constant")
+ fminimaxChecktype("fminimax", minmaxBeq, "beq", 6, "constant")
+
+ // Check if Aeq and beq of proper dimensions
+ if(minmaxAeq <> [] & minmaxBeq == []) then
+ errmsg = msprintf(gettext("%s: Incompatible input arguments #%d and #%d: matrix Aeq is empty, but the column vector beq is not empty"), "fminimax", 5, 6)
+ error(errmsg)
+ end
+
+ if(minmaxAeq == [] & minmaxBeq <> []) then
+ errmsg = msprintf(gettext("%s: Incompatible input arguments #%d and #%d: matrix Aeq is not empty, but the column vector beq is empty"), "fminimax", 5, 6)
+ error(errmsg)
+ end
+
+ minmaxNumrowAeq = size(minmaxAeq,"r")
+ if(minmaxAeq <> []) then
+ fminimaxCheckdims("fminimax", minmaxAeq, "Aeq", 5, [minmaxNumrowAeq minmaxNumvar])
+ fminimaxCheckvector("fminimax", minmaxBeq, "beq", 6, minmaxNumrowAeq)
+ minmaxBeq = minmaxBeq(:)
+ end
+
+ // Proper initialisation of minmaxLb and minmaxUb
+ if(minmaxRhs < 7) then // if minmaxLb and minmaxUb are not provided, declare as empty
+ minmaxLb = []
+ minmaxUb = []
+ else
+ minmaxLb = varargin(7)
+ minmaxUb = varargin(8)
+ end
+
+ fminimaxChecktype("fminimax", minmaxLb, "lb", 7, "constant")
+ fminimaxChecktype("fminimax", minmaxUb, "ub", 8, "constant")
+
+ // Check dimensions of minmaxLb and minmaxUb
+ if(minmaxLb <> []) then
+ fminimaxCheckvector("fminimax", minmaxLb, "lb", 7, minmaxNumvar)
+ minmaxLb = minmaxLb(:)
+ end
+
+ if(minmaxUb <> []) then
+ fminimaxCheckvector("fminimax", minmaxUb, "ub", 8, minmaxNumvar)
+ minmaxUb = minmaxUb(:)
+ end
+
+ // Proper Initialisation of minmaxNonlinfun
+ if(minmaxRhs < 9) then // if minmaxNonlinfun is not provided, declare as empty
+ minmaxNonlinfun = []
+ else
+ minmaxNonlinfun = varargin(9)
+ end
+
+ // fmincon library of scilab gives error when 'c' component of minmaxNonlinfun empty
+ // add a trivial case of -5 <= 0 to c to bypass this error
+ if(minmaxNonlinfun == []) then
+ function [c,ceq] = t(z)
+ c = []
+ ceq = []
+ endfunction
+ minmaxNonlinfun = t
+ end
+
+ fminimaxChecktype("fminimax", minmaxNonlinfun, "nonlinfun", 9, "function")
+
+ //To check, Whether minimaxOptions is been entered by user
+ if ( minmaxRhs<10 ) then
+ minmaxUserOptions = list();
+ else
+ minmaxUserOptions = varargin(10); //Storing the 3rd Input minmaxUserOptionseter in intermediate list named 'minmaxUserOptions'
+ end
+
+ //If minimaxOptions is entered then checking its type for 'list'
+ if (type(minmaxUserOptions) ~= 15) then
+ errmsg = msprintf(gettext("%s: minimaxOptions (10th parameter) should be a list"), "fminimax");
+ error(errmsg);
+ end
+
+ //If minimaxOptions is entered then checking whether even number of entires are entered
+ if (modulo(size(minmaxUserOptions),2)) then
+ errmsg = msprintf(gettext("%s: Size of minimaxOptions (list) should be even"), "fminimax");
+ error(errmsg);
+ end
+
+ //Flags to check whether Gradient is "ON"/"OFF" and store values of user options
+ flag1=0;
+ flag2=0;
+ minmaxMaxIter = 3000
+ minmaxCPU = 600
+ minmaxFGrad=[];
+ minmaxCGrad=[];
+
+ //To check the User Entry for Options and storing it
+ for i = 1:(size(minmaxUserOptions))/2
+ select minmaxUserOptions(2*i-1)
+ case "MaxIter" then
+ minmaxIter = minmaxUserOptions(2*i); //Setting the Maximum Iteration as per user entry
+
+ case "CpuTime" then
+ minmaxCPU = minmaxUserOptions(2*i); //Setting the Maximum CPU Time as per user entry
+
+ case "GradObj" then
+ flag1=1;
+ minmaxFGrad = minmaxUserOptions(2*i);
+
+ case "GradCon" then
+ flag2=1;
+ minmaxCGrad = minmaxUserOptions(2*i);
+
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized minmaxUserOptionseter name ''%s''."), "fminimax", minmaxUserOptions(2*i-1));
+ error(errmsg)
+ end
+ end
+
+ // Checking if minmaxFGrad and minmaxCGrad are functions
+ if (flag1==1) then
+ if (type(minmaxFGrad) ~= 11 & type(minmaxFGrad) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Objective"), "fminimax");
+ error(errmsg);
+ end
+ end
+
+ if (flag2==1) then
+ if (type(minmaxCGrad) ~= 11 & type(minmaxCGrad) ~= 13) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Nonlinfun"), "fminimax");
+ error(errmsg);
+ end
+ end
+
+
+ // Reformulating the problem fminimax to fmincon
+ minmaxObjfunval = minmaxObjfun(minmaxStartpoint)
+ minmaxStartpoint(minmaxNumvar+1) = max(minmaxObjfunval)
+
+ if(minmaxA <> []) then
+ minmaxA = [minmaxA, zeros(minmaxNumrowA,1)]
+ end
+ if(minmaxAeq <> []) then
+ minmaxAeq = [minmaxAeq, zeros(minmaxNumrowAeq,1)]
+ end
+ if(minmaxLb <> []) then
+ minmaxLb(minmaxNumvar+1) = -%inf
+ end
+ if(minmaxUb <> []) then
+ minmaxUb(minmaxNumvar+1) = +%inf
+ end
+
+ // function handle defining the additional inequalities
+ function temp = minmaxAddIneq(z)
+ temp = minmaxObjfun(z) - z(minmaxNumvar+1)
+ endfunction
+
+ // function handle defining new objective function
+ function newfunc = newObjfun(z)
+ newfunc = z(minmaxNumvar+1)
+ endfunction
+
+ // function handle defining add_ineq derivative using numderivative
+ function func = minmaxObjDer(z)
+ func = numderivative(minmaxAddIneq,z)
+ endfunction
+
+ // function handle defining minmaxNonlinfun derivative using numderivative
+ function [dc,dceq] = minmaxNonlinDer(z)
+ // function handle extracting c and ceq components from minmaxNonlinfun
+ function foo = minmaxC(z)
+ [foo,tmp1] = minmaxNonlinfun(z)
+ foo = foo'
+ endfunction
+
+ function foo = minmaxCEQ(z)
+ [tmp1,foo] = minmaxNonlinfun(z)
+ foo = foo'
+ endfunction
+
+ dc = numderivative(minmaxC,z)
+ dceq = numderivative(minmaxCEQ,z)
+ endfunction
+
+ // function handle defining new minmaxNonlinfun function
+ function [nc,nceq] = newNonlinfun(z)
+ [nc,nceq] = minmaxNonlinfun(z)
+ // add inequalities of the form Fi(x) - y <= 0
+ tmp = [minmaxObjfun(z) - z(minmaxNumvar+1)]'
+ nc = [nc, tmp]
+ endfunction
+
+ // function handle defining new gradient function for non-linear constraints
+ // this function passed when the gradient feature is on
+ function [dnc,dnceq] = newCGrad(z)
+
+ // if constraint gradient present use it
+ if(flag2 == 1) then
+ [dnc, dnceq] = minmaxCGrad(z)
+ dnc = [dnc, zeros(size(dnc,'r'),1)]
+ dnceq = [dnceq, zeros(size(dnceq,'r'),1)]
+ else
+ // else use numderivative method to calculate gradient of constraints
+ [dnc, dnceq] = minmaxNonlinDer(z)
+ end
+
+ // if objective gradient is present use it
+ if(flag1 == 1) then
+ derObjfun = minmaxFGrad(z)
+ mderObjfun = [derObjfun, -1*ones(size(derObjfun,'r'),1)]
+ dnc = [dnc; mderObjfun]
+ else
+ // else use numderivative to calculate gradient of set of obj functions
+ derObjfun = minmaxObjDer(z)
+ dnc = [dnc; derObjfun]
+ end
+ endfunction
+
+ // to be passed as minimaxOptions to fmincon
+ if(flag1 == 1 | flag2 == 1) then
+ minmaxPassOptions = list("MaxIter", minmaxMaxIter, "CpuTime", minmaxCPU, "GradCon", newCGrad)
+ [x,fval,exitflag,output,lambda] = ...
+ fmincon(newObjfun,minmaxStartpoint,minmaxA,minmaxB,minmaxAeq,minmaxBeq,minmaxLb,minmaxUb,newNonlinfun,minmaxPassOptions)
+
+ x = x(1:minmaxNumvar)
+ fval = minmaxObjfun(x)
+ maxfval = max(fval)
+ else
+ minmaxPassOptions = list("MaxIter", minmaxMaxIter, "CpuTime", minmaxCPU)
+ [x,fval,exitflag,output,lambda] = ...
+ fmincon(newObjfun,minmaxStartpoint,minmaxA,minmaxB,minmaxAeq,minmaxBeq,minmaxLb,minmaxUb,newNonlinfun,minmaxPassOptions)
+
+ x = x(1:minmaxNumvar)
+ fval = minmaxObjfun(x)
+ maxfval = max(fval)
+ end
+
+
+endfunction
diff --git a/macros/fminimaxCheckdims.bin b/macros/fminimaxCheckdims.bin
new file mode 100644
index 0000000..be1ed46
--- /dev/null
+++ b/macros/fminimaxCheckdims.bin
Binary files differ
diff --git a/macros/fminimaxCheckdims.sci b/macros/fminimaxCheckdims.sci
new file mode 100644
index 0000000..83cb5b5
--- /dev/null
+++ b/macros/fminimaxCheckdims.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 = 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
new file mode 100644
index 0000000..7889084
--- /dev/null
+++ b/macros/fminimaxChecklhs.bin
Binary files differ
diff --git a/macros/fminimaxChecklhs.sci b/macros/fminimaxChecklhs.sci
new file mode 100644
index 0000000..78e4013
--- /dev/null
+++ b/macros/fminimaxChecklhs.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 = 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
new file mode 100644
index 0000000..6b190f7
--- /dev/null
+++ b/macros/fminimaxCheckrhs.bin
Binary files differ
diff --git a/macros/fminimaxCheckrhs.sci b/macros/fminimaxCheckrhs.sci
new file mode 100644
index 0000000..7877153
--- /dev/null
+++ b/macros/fminimaxCheckrhs.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 = 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
new file mode 100644
index 0000000..4f42fe0
--- /dev/null
+++ b/macros/fminimaxChecktype.bin
Binary files differ
diff --git a/macros/fminimaxChecktype.sci b/macros/fminimaxChecktype.sci
new file mode 100644
index 0000000..48514b6
--- /dev/null
+++ b/macros/fminimaxChecktype.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 = 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
new file mode 100644
index 0000000..28af2c5
--- /dev/null
+++ b/macros/fminimaxCheckvector.bin
Binary files differ
diff --git a/macros/fminimaxCheckvector.sci b/macros/fminimaxCheckvector.sci
new file mode 100644
index 0000000..87c8553
--- /dev/null
+++ b/macros/fminimaxCheckvector.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 = 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
+
+
+
diff --git a/macros/fminunc.bin b/macros/fminunc.bin
new file mode 100644
index 0000000..b65c851
--- /dev/null
+++ b/macros/fminunc.bin
Binary files differ
diff --git a/macros/fminunc.sci b/macros/fminunc.sci
new file mode 100644
index 0000000..07fa92a
--- /dev/null
+++ b/macros/fminunc.sci
@@ -0,0 +1,427 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// 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
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+function [xopt,fopt,exitflag,output,gradient,hessian] = fminunc (varargin)
+ // Solves a multi-variable unconstrainted optimization problem
+ //
+ // Calling Sequence
+ // xopt = fminunc(f,x0)
+ // xopt = fminunc(f,x0,options)
+ // [xopt,fopt] = fminunc(.....)
+ // [xopt,fopt,exitflag]= fminunc(.....)
+ // [xopt,fopt,exitflag,output]= fminunc(.....)
+ // [xopt,fopt,exitflag,output,gradient]=fminunc(.....)
+ // [xopt,fopt,exitflag,output,gradient,hessian]=fminunc(.....)
+ //
+ // Parameters
+ // f : a function, representing the objective function of the problem
+ // x0 : a vector of doubles, containing the starting of variables.
+ // options: a list, containing the option for user to specify. See below for details.
+ // xopt : a vector of doubles, the computed solution of the optimization problem.
+ // fopt : a scalar of double, the function value at x.
+ // exitflag : a scalar of integer, containing the flag which denotes the reason for termination of algorithm. See below for details.
+ // output : a structure, containing the information about the optimization. See below for details.
+ // gradient : a vector of doubles, containing the the gradient of the solution.
+ // hessian : a matrix of doubles, containing the the hessian of the solution.
+ //
+ // Description
+ // Search the minimum of an unconstrained optimization problem specified by :
+ // Find the minimum of f(x) such that
+ //
+ // <latex>
+ // \begin{eqnarray}
+ // &\mbox{min}_{x}
+ // & f(x)\\
+ // \end{eqnarray}
+ // </latex>
+ //
+ // The routine calls Ipopt for solving the Un-constrained Optimization problem, Ipopt is a library written in C++.
+ //
+ // The options allows the user to set various parameters of the Optimization problem.
+ // It should be defined as type "list" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---], "Gradient", ---, "Hessian", ---);</listitem>
+ // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem>
+ // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem>
+ // <listitem>Gradient : a function, representing the gradient function of the Objective in Vector Form.</listitem>
+ // <listitem>Hessian : a function, representing the hessian function of the Objective in Symmetric Matrix Form.</listitem>
+ // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem>
+ // </itemizedlist>
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=2 : Maximum CPU Time exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=3 : Stop at Tiny Step.</listitem>
+ // <listitem>exitflag=4 : Solved To Acceptable Level.</listitem>
+ // <listitem>exitflag=5 : Converged to a point of local infeasibility.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.Iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.Cpu_Time: The total cpu-time spend during the search</listitem>
+ // <listitem>output.Objective_Evaluation: The number of Objective Evaluations performed during the search</listitem>
+ // <listitem>output.Dual_Infeasibility: The Dual Infeasiblity of the final soution</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // //Find x in R^2 such that it minimizes the Rosenbrock function
+ // //f = 100*(x2 - x1^2)^2 + (1-x1)^2
+ // //Objective function to be minimised
+ // function y= f(x)
+ // y= 100*(x(2) - x(1)^2)^2 + (1-x(1))^2;
+ // endfunction
+ // //Starting point
+ // x0=[-1,2];
+ // //Gradient of objective function
+ // function y= fGrad(x)
+ // y= [-400*x(1)*x(2) + 400*x(1)^3 + 2*x(1)-2, 200*(x(2)-x(1)^2)];
+ // endfunction
+ // //Hessian of Objective Function
+ // function y= fHess(x)
+ // y= [1200*x(1)^2- 400*x(2) + 2, -400*x(1);-400*x(1), 200 ];
+ // endfunction
+ // //Options
+ // options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+ // //Calling Ipopt
+ // [xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Find x in R^2 such that the below function is minimum
+ // //f = x1^2 + x2^2
+ // //Objective function to be minimised
+ // function y= f(x)
+ // y= x(1)^2 + x(2)^2;
+ // endfunction
+ // //Starting point
+ // x0=[2,1];
+ // //Calling Ipopt
+ // [xopt,fopt]=fminunc(f,x0)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //The below problem is an unbounded problem:
+ // //Find x in R^2 such that the below function is minimum
+ // //f = - x1^2 - x2^2
+ // //Objective function to be minimised
+ // function y= f(x)
+ // y= -x(1)^2 - x(2)^2;
+ // endfunction
+ // //Starting point
+ // x0=[2,1];
+ // //Gradient of objective function
+ // function y= fGrad(x)
+ // y= [-2*x(1),-2*x(2)];
+ // endfunction
+ // //Hessian of Objective Function
+ // function y= fHess(x)
+ // y= [-2,0;0,-2];
+ // endfunction
+ // //Options
+ // options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+ // //Calling Ipopt
+ // [xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+ // Authors
+ // R.Vidyadhar , Vignesh Kannan
+
+
+ //To check the number of input and output arguments
+ [lhs , rhs] = argn();
+
+ //To check the number of arguments given by the user
+ if ( rhs<2 | rhs>5 ) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 2 or 5"), "fminunc", rhs);
+ error(errmsg)
+ end
+
+ //Storing the 1st and 2nd Input Parameters
+ fun = varargin(1);
+ x0 = varargin(2);
+
+ //To check whether the 1st Input argument(f) is a function or not
+ if (type(f) ~= 13 & type(f) ~= 11) then
+ errmsg = msprintf(gettext("%s: Expected function for Objective "), "fminunc");
+ error(errmsg);
+ end
+
+ //To check whether the 2nd Input argument(x0) is a vector/scalar
+ if (type(x0) ~= 1) then
+ errmsg = msprintf(gettext("%s: Expected Vector/Scalar for Starting Point"), "fminunc");
+ error(errmsg);
+ end
+
+ //To check and convert the 2nd Input argument(x0) to a row vector
+ if((size(x0,1)~=1) & (size(x0,2)~=1)) then
+ errmsg = msprintf(gettext("%s: Expected Row Vector or Column Vector for x0 (Initial Value) "), "fminunc", rhs);
+ error(errmsg);
+ else
+ if(size(x0,2)==1) then
+ x0=x0'; //Converting x0 to a row vector, if it is a column vector
+ else
+ x0=x0; //Retaining the same, if it is already a row vector
+ end
+ s=size(x0);
+ end
+
+
+ //To check the match between f (1st Parameter) and x0 (2nd Parameter)
+ if(execstr('init=fun(x0)','errcatch')==21) then
+ errmsg = msprintf(gettext("%s: Objective function and x0 did not match"), "fminunc");
+ error(errmsg);
+ end
+
+ //Converting the User defined Objective function into Required form (Error Detectable)
+ function [y,check] = f(x)
+ if(execstr('y=fun(x)','errcatch')==32 | execstr('y=fun(x)','errcatch')==27)
+ y=0;
+ check=1;
+ else
+ y=fun(x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+
+ //To check whether options has been entered by user
+ if ( rhs<3 ) then
+ param = list();
+ else
+ param =varargin(3); //Storing the 3rd Input Parameter in an intermediate list named 'param'
+
+ end
+
+ //If options has been entered, then check its type for 'list'
+ if (type(param) ~= 15) then
+ errmsg = msprintf(gettext("%s: 3rd Input parameter should be a list (ie. Options) "), "fminunc");
+ error(errmsg);
+ end
+
+ //If options has been entered, then check whether an even number of entires has been entered
+ if (modulo(size(param),2)) then
+ errmsg = msprintf(gettext("%s: Size of parameters should be even"), "fminunc");
+ error(errmsg);
+ end
+
+ //Defining a function to calculate Gradient or Hessian if the respective user entry is OFF
+ function [y,check]=gradhess(x,t)
+ if t==1 then //To return Gradient
+ if(execstr('y=numderivative(fun,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ y=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ else //To return Hessian
+ if(execstr('[grad,y]=numderivative(fun,x)','errcatch')==10000)
+ y=0;
+ check=1;
+ else
+ [grad,y]=numderivative(fun,x);
+ if (isreal(y)==%F) then
+ y=0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ end
+ endfunction
+
+ //To set default values for options, if user doesn't enter options
+ options = list("MaxIter", [3000], "CpuTime", [600]);
+
+ //Flags to check whether Gradient is "ON"/"OFF" and Hessian is "ON"/"OFF"
+ flag1=0;
+ flag2=0;
+ fGrad=[];
+ fGrad1=[];
+ fHess=[];
+ fHess1=[];
+
+ //To check the user entry for options and store it
+ for i = 1:(size(param))/2
+ select param(2*i-1)
+ case "MaxIter" then
+ options(2*i) = param(2*i); //Setting the maximum number of iterations as per user entry
+ case "CpuTime" then
+ options(2*i) = param(2*i); //Setting the maximum CPU time as per user entry
+ case "Gradient" then
+ flag1 = 1;
+ fGrad = param(2*i);
+ case "Hessian" then
+ flag2 = 1;
+ fHess = param(2*i);
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fminbnd", param(2*i-1));
+ error(errmsg)
+ end
+ end
+
+
+ //To check for correct input of Gradient and Hessian functions from the user
+ if (flag1==1) then
+ if (type(fGrad) ~= 13 & type(fGrad) ~= 11) then
+ errmsg = msprintf(gettext("%s: Expected function for Gradient of Objective"), "fminunc");
+ error(errmsg);
+ end
+
+ if(execstr('samplefGrad=fGrad(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Gradient function of Objective and x0 did not match"), "fminunc");
+ error(errmsg);
+ end
+
+ samplefGrad=fGrad(x0);
+
+ if (size(samplefGrad,1)==s(2) & size(samplefGrad,2)==1) then
+ elseif (size(samplefGrad,1)==1 & size(samplefGrad,2)==s(2)) then
+ elseif (size(samplefGrad,1)~=1 & size(samplefGrad,2)~=1) then
+ errmsg = msprintf(gettext("%s: Wrong Input for Objective Gradient function(3rd Parameter)---->Row Vector function is Expected"), "fminunc");
+ error(errmsg);
+ end
+
+ function [y,check] = fGrad1(x)
+ if(execstr('y=fGrad(x)','errcatch')==32 | execstr('y=fGrad(x)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y=fGrad(x);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+ end
+ if (flag2==1) then
+ if (type(fHess) ~= 13 & type(fHess) ~= 11) then
+ errmsg = msprintf(gettext("%s: Expected function for Hessian of Objective"), "fminunc");
+ error(errmsg);
+ end
+
+ if(execstr('samplefHess=fHess(x0)','errcatch')==21)
+ errmsg = msprintf(gettext("%s: Hessian function of Objective and x0 did not match"), "fminunc");
+ error(errmsg);
+ end
+
+ samplefHess=fHess(x0);
+
+ if(size(samplefHess,1)~=s(2) | size(samplefHess,2)~=s(2)) then
+ errmsg = msprintf(gettext("%s: Wrong Input for Objective Hessian function(3rd Parameter)---->Symmetric Matrix function is Expected "), "fminunc");
+ error(errmsg);
+ end
+
+ function [y,check] = fHess1(x)
+ if(execstr('y=fHess(x)','errcatch')==32 | execstr('y=fHess(x)','errcatch')==27)
+ y = 0;
+ check=1;
+ else
+ y=fHess(x);
+ if (isreal(y)==%F) then
+ y = 0;
+ check=1;
+ else
+ check=0;
+ end
+ end
+ endfunction
+ end
+
+ //Calling the Ipopt function for solving the above problem
+ [xopt,fopt,status,iter,cpu,obj_eval,dual,gradient, hessian1] = solveminuncp(f,gradhess,flag1,fGrad1,flag2,fHess1,x0,options);
+
+ //Calculating the values for output
+ xopt = xopt';
+ exitflag = status;
+ output = struct("Iterations", [],"Cpu_Time",[],"Objective_Evaluation",[],"Dual_Infeasibility",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ output.Objective_Evaluation = obj_eval;
+ output.Dual_Infeasibility = dual;
+
+ //Converting hessian of order (1 x (numberOfVariables)^2) received from Ipopt to order (numberOfVariables x numberOfVariables)
+ s=size(gradient)
+ for i =1:s(2)
+ for j =1:s(2)
+ hessian(i,j)= hessian1(j+((i-1)*s(2)))
+ end
+ end
+
+
+ //In the cases of the problem not being solved, return NULL to the output matrices
+ if( status~=0 & status~=1 & status~=2 & status~=3 & status~=4 & status~=7 ) then
+ xopt=[]
+ fopt=[]
+ output = struct("Iterations", [],"Cpu_Time",[]);
+ output.Iterations = iter;
+ output.Cpu_Time = cpu;
+ gradient=[]
+ hessian=[]
+ end
+
+
+ //To print output message
+ select status
+
+ case 0 then
+ printf("\nOptimal Solution Found.\n");
+ case 1 then
+ printf("\nMaximum Number of Iterations Exceeded. Output may not be optimal.\n");
+ case 2 then
+ printf("\nMaximum CPU Time exceeded. Output may not be optimal.\n");
+ case 3 then
+ printf("\nStop at Tiny Step\n");
+ case 4 then
+ printf("\nSolved To Acceptable Level\n");
+ case 5 then
+ printf("\nConverged to a point of local infeasibility.\n");
+ case 6 then
+ printf("\nStopping optimization at current point as requested by user.\n");
+ case 7 then
+ printf("\nFeasible point for square problem found.\n");
+ case 8 then
+ printf("\nIterates diverging; problem might be unbounded.\n");
+ case 9 then
+ printf("\nRestoration Failed!\n");
+ case 10 then
+ printf("\nError in step computation (regularization becomes too large?)!\n");
+ case 12 then
+ printf("\nProblem has too few degrees of freedom.\n");
+ case 13 then
+ printf("\nInvalid option thrown back by Ipopt\n");
+ case 14 then
+ printf("\nNot enough memory.\n");
+ case 15 then
+ printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n");
+ else
+ printf("\nInvalid status returned. Notify the Toolbox authors\n");
+ break;
+ end
+
+
+endfunction
diff --git a/macros/lib b/macros/lib
index 60efd81..b034ee7 100644
--- a/macros/lib
+++ b/macros/lib
Binary files differ
diff --git a/macros/linprog.bin b/macros/linprog.bin
new file mode 100644
index 0000000..b9ba12a
--- /dev/null
+++ b/macros/linprog.bin
Binary files differ
diff --git a/macros/linprog.sci b/macros/linprog.sci
new file mode 100644
index 0000000..4c949ba
--- /dev/null
+++ b/macros/linprog.sci
@@ -0,0 +1,199 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// 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
+// Author: Guru Pradeep Reddy, Bhanu Priya Sayal
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+
+function [xopt,fopt,exitflag,output,lambda] = linprog (varargin)
+ // Solves a linear programming problem.
+ //
+ // Calling Sequence
+ // xopt = linprog(c,A,b)
+ // xopt = linprog(c,A,b,Aeq,beq)
+ // xopt = linprog(c,A,b,Aeq,beq,lb,ub)
+ // xopt = linprog(c,A,b,Aeq,beq,lb,ub,param)
+ // [xopt, fopt, exitflag, output, lambda] = linprog(file)
+ // [xopt,fopt,exitflag,output,lambda] = linprog( ... )
+ //
+ // Parameters
+ // c : a vector of double, contains coefficients of the variables in the objective
+ // A : a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.
+ // b : a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b.
+ // Aeq : a matrix of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.
+ // beq : a vector of double, represents the linear coefficients in the equality constraints Aeqâ‹…x = beq.
+ // lb : Lower bounds, specified as a vector or array of double. lb represents the lower bounds elementwise in lb ≤ x ≤ ub.
+ // ub : Upper bounds, specified as a vector or array of double. ub represents the upper bounds elementwise in lb ≤ x ≤ ub.
+ // options : a list containing the parameters to be set.
+ // file : a string describing the path to the mps file.
+ // xopt : a vector of double, the computed solution of the optimization problem.
+ // fopt : a double, the value of the function at x.
+ // status : status flag returned from symphony. See below for details.
+ // output : The output data structure contains detailed information about the optimization process. See below for details.
+ // lambda : The structure consist of the Lagrange multipliers at the solution of problem. See below for details.
+ //
+ // Description
+ // OSI-CLP is used for solving the linear programming problems, OSI-CLP is a library written in C++.
+ // Search the minimum of a constrained linear programming problem specified by :
+ //
+ // <latex>
+ // \begin{eqnarray}
+ // &\mbox{min}_{x}
+ // & c^Tâ‹…x \\
+ // & \text{subject to} & Aâ‹…x \leq b \\
+ // & & Aeqâ‹…x = beq \\
+ // & & lb \leq x \leq ub \\
+ // \end{eqnarray}
+ // </latex>
+ // The routine calls Clp for solving the linear programming problem, Clp is a library written in C++.
+ //
+ // The exitflag allows to know the status of the optimization which is given back by Ipopt.
+ // <itemizedlist>
+ // <listitem>exitflag=0 : Optimal Solution Found </listitem>
+ // <listitem>exitflag=1 : Primal Infeasible </listitem>
+ // <listitem>exitflag=2 : Dual Infeasible</listitem>
+ // <listitem>exitflag=3 : Maximum Number of Iterations Exceeded. Output may not be optimal.</listitem>
+ // <listitem>exitflag=4 : Solution Abandoned</listitem>
+ // <listitem>exitflag=5 : Primal objective limit reached.</listitem>
+ // <listitem>exitflag=6 : Dual objective limit reached.</listitem>
+ // </itemizedlist>
+ //
+ // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/
+ //
+ // The output data structure contains detailed informations about the optimization process.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>output.iterations: The number of iterations performed during the search</listitem>
+ // <listitem>output.constrviolation: The max-norm of the constraint violation.</listitem>
+ // </itemizedlist>
+ //
+ // The lambda data structure contains the Lagrange multipliers at the end
+ // of optimization. In the current version the values are returned only when the the solution is optimal.
+ // It has type "struct" and contains the following fields.
+ // <itemizedlist>
+ // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem>
+ // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem>
+ // <listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem>
+ // <listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem>
+ // </itemizedlist>
+ //
+ // Examples
+ // //Optimal problems
+ // //Linear program, linear inequality constraints
+ // c=[-1,-1/3]'
+ // A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+ // b=[2,1,2,1,-1,2]
+ // [xopt,fopt,exitflag,output,lambda]=linprog(c, A, b)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Linear program with Linear Inequalities and Equalities`
+ // c=[-1,-1/3]'
+ // A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+ // b=[2,1,2,1,-1,2]
+ // Aeq=[1,1/4]
+ // beq=[1/2]
+ // [xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Linear program with all constraint types
+ // c=[-1,-1/3]'
+ // A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+ // b=[2,1,2,1,-1,2]
+ // Aeq=[1,1/4]
+ // beq=[1/2]
+ // lb=[-1,-0.5]
+ // ub=[1.5,1.25]
+ // [xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Primal Infeasible Problem
+ // c=[-1,-1,-1]'
+ // A=[1,2,-1]
+ // b=[-4]
+ // Aeq=[1,5,3;1,1,0]
+ // beq=[10,100]
+ // lb=[0,0,0]
+ // ub=[%inf,%inf,%inf]
+ // [xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // //Dual Infeasible Problem
+ // c=[3,5,-7]'
+ // A=[-1,-1,4;1,1,4]
+ // b=[-8,5]
+ // Aeq=[]
+ // beq=[]
+ // lb=[-%inf,-%inf,-%inf]
+ // ub=[%inf,%inf,%inf]
+ // [xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+ // // Press ENTER to continue
+ //
+ // Examples
+ // filepath = get_absolute_file_path('linprog.dem.sce');
+ // filepath = filepath + "exmip1.mps"
+ // [xopt,fopt,exitflag,output,lambda] =linprog(filepath)
+ // Authors
+ // Bhanu Priya Sayal, Guru Pradeep Reddy
+
+ if(type(varargin(1))==1) then
+ [lhs , rhs] = argn();
+ //To check the number of argument given by user
+ if ( rhs < 3 | rhs == 4 | rhs == 6 | rhs >8 ) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [3 5 7 8]"), "linprog", rhs);
+ error(errmsg)
+ end
+
+ c = varargin(1);
+ A = varargin(2);
+ b = varargin(3);
+
+ if ( rhs<4 ) then
+ Aeq = []
+ beq = []
+ else
+ Aeq = varargin(4);
+ beq = varargin(5);
+ end
+
+ if ( rhs<6 ) then
+ lb = [];
+ ub = [];
+ else
+ lb = varargin(6);
+ ub = varargin(7);
+ end
+
+ if ( rhs<8 | size(varargin(8)) ==0 ) then
+ param = list();
+ else
+ param =varargin(8);
+ end
+ [xopt,fopt,exitflag,output,lambda]=matrix_linprog(c,A,b,Aeq,beq,lb,ub,param);
+ elseif(type(varargin(1))==10) then
+
+ [lhs , rhs] = argn();
+
+ //To check the number of argument given by user
+ if ( rhs < 1 | rhs > 2) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [1 2]"),"linprog",rhs);
+ error(errmsg)
+ end
+ mpsFile = varargin(1);
+ if ( rhs<2 | size(varargin(2)) ==0 ) then
+ param = list();
+ else
+ param =varargin(2);
+ end
+ [xopt,fopt,exitflag,output,lambda]=mps_linprog(mpsFile,param);
+ end
+
+endfunction
diff --git a/macros/lsqlin.bin b/macros/lsqlin.bin
index eb02534..7018f4a 100644
--- a/macros/lsqlin.bin
+++ b/macros/lsqlin.bin
Binary files differ
diff --git a/macros/lsqlin.sci b/macros/lsqlin.sci
index 960b4db..97aaae6 100644
--- a/macros/lsqlin.sci
+++ b/macros/lsqlin.sci
@@ -151,6 +151,11 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin)
b = varargin(4);
nbVar = size(C,2);
+ if(nbVar == 0) then
+ errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"), "lsqlin");
+ error(errmsg);
+ end
+
if ( rhs<5 ) then
Aeq = []
beq = []
diff --git a/macros/lsqnonneg.bin b/macros/lsqnonneg.bin
index 7ea7f4a..39c553b 100644
--- a/macros/lsqnonneg.bin
+++ b/macros/lsqnonneg.bin
Binary files differ
diff --git a/macros/lsqnonneg.sci b/macros/lsqnonneg.sci
index 3b152bf..3e5ea81 100644
--- a/macros/lsqnonneg.sci
+++ b/macros/lsqnonneg.sci
@@ -97,6 +97,12 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin)
C = varargin(1);
d = varargin(2);
nbVar = size(C,2);
+
+ if(nbVar == 0) then
+ errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"), "lsqnonneg");
+ error(errmsg);
+ end
+
if ( rhs<3 | size(varargin(3)) ==0 ) then
param = list();
else
diff --git a/macros/matrix_linprog.bin b/macros/matrix_linprog.bin
new file mode 100644
index 0000000..21e525c
--- /dev/null
+++ b/macros/matrix_linprog.bin
Binary files differ
diff --git a/macros/matrix_linprog.sci b/macros/matrix_linprog.sci
new file mode 100755
index 0000000..1f6a6bf
--- /dev/null
+++ b/macros/matrix_linprog.sci
@@ -0,0 +1,245 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Guru Pradeep Reddy, Bhanu Priya Sayal
+// Organization: FOSSEE, IIT Bombay
+// Email: gurupradeept@gmail.com, bhanupriyasayal@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
+
+
+function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin)
+//To check the number of input and output argument
+ [lhs , rhs] = argn();
+
+ c = [];
+ A = [];
+ b = [];
+ Aeq = [];
+ beq = [];
+ lb = [];
+ ub = [];
+ options = list();
+
+//To check the number of argument given by user
+ if ( rhs < 3 | rhs == 4 | rhs == 6 | rhs >8 ) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [3 5 7 8]"), "linprog", rhs);
+ error(errmsg)
+ end
+
+ c = varargin(1);
+
+ if (size(c,2)~=1) then
+ errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "linprog");
+ error(errmsg);
+ end
+
+ if(size(c,2) == 0) then
+ errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"), "linprog");
+ error(errmsg);
+ end
+
+ nbVar = size(c,1);
+ A = varargin(2);
+ b = varargin(3);
+
+ if ( rhs<4 ) then
+ Aeq = []
+ beq = []
+ else
+ Aeq = varargin(4);
+ beq = varargin(5);
+ end
+
+ if ( rhs<6 ) then
+ lb = [];
+ ub = [];
+ else
+ lb = varargin(6);
+ ub = varargin(7);
+ end
+
+ if ( rhs<8 | size(varargin(8)) ==0 ) then
+ param = list();
+ else
+ param =varargin(8);
+ end
+
+ nbConInEq = size(A,1);
+ nbConEq = size(Aeq,1);
+
+ if (size(lb,2)== [nbVar]) then
+ lb = lb';
+ end
+
+ if (size(ub,2)== [nbVar]) then
+ ub = ub';
+ end
+
+ if (size(b,2)== [nbConInEq]) then
+ b = b';
+ end
+
+ if (size(beq,2)== [nbConEq]) then
+ beq = beq';
+ end
+
+
+ if (size(lb,2)==0) then
+ lb = repmat(-%inf,nbVar,1);
+ end
+
+ if (size(ub,2)==0) then
+ ub = repmat(%inf,nbVar,1);
+ end
+
+ if (type(param) ~= 15) then
+ errmsg = msprintf(gettext("%s: options should be a list "), "linprog");
+ error(errmsg);
+ end
+
+
+ if (modulo(size(param),2)) then
+ errmsg = msprintf(gettext("%s: Size of parameters should be even"), "linprog");
+ error(errmsg);
+ end
+
+ options = list("MaxIter", [3000]);
+
+ for i = 1:(size(param))/2
+
+ select param(2*i-1)
+ case "MaxIter" then
+ options(2*i) = param(2*i);
+ else
+ errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1));
+ error(errmsg)
+ end
+ end
+
+ //Check the size of inequality constraint which should be equal to the number of variables
+ if ( size(A,2) ~= nbVar & size(A,2) ~= 0) then
+ errmsg = msprintf(gettext("%s: The number of columns in A must be the same as the number of elements of c"), "linprog");
+ error(errmsg);
+ end
+
+ //Check the size of equality constraint which should be equal to the number of variables
+ if ( size(Aeq,2) ~= nbVar & size(Aeq,2) ~= 0 ) then
+ errmsg = msprintf(gettext("%s: The number of columns in Aeq must be the same as the number of elements of c"), "linprog");
+ error(errmsg);
+ end
+
+ //Check the size of Lower Bound which should be equal to the number of variables
+ if ( size(lb,1) ~= nbVar) then
+ errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "linprog");
+ error(errmsg);
+ end
+
+ //Check the size of Upper Bound which should equal to the number of variables
+ if ( size(ub,1) ~= nbVar) then
+ errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "linprog");
+ error(errmsg);
+ end
+ //Check the size of constraints of Lower Bound which should equal to the number of constraints
+ if ( size(b,1) ~= nbConInEq & size(b,2) ~= 0) then
+ errmsg = msprintf(gettext("%s: The number of rows in A must be the same as the number of elements of b"), "linprog");
+ error(errmsg);
+ end
+
+ //Check the size of constraints of Upper Bound which should equal to the number of constraints
+ if ( size(beq,1) ~= nbConEq & size(beq,2) ~= 0) then
+ errmsg = msprintf(gettext("%s: The number of rows in Aeq must be the same as the number of elements of beq"), "linprog");
+ error(errmsg);
+ end
+
+ //Check if the user gives a matrix instead of a vector
+
+ if (size(lb,1)~=1)& (size(lb,2)~=1) then
+ errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "linprog");
+ error(errmsg);
+ end
+
+ if (size(ub,1)~=1)& (size(ub,2)~=1) then
+ errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "linprog");
+ error(errmsg);
+ end
+
+ if (nbConInEq) then
+ if ((size(b,1)~=1)& (size(b,2)~=1)) then
+ errmsg = msprintf(gettext("%s: Constraint Lower Bound should be a vector"), "linprog");
+ error(errmsg);
+ end
+ end
+
+ if (nbConEq) then
+ if (size(beq,1)~=1)& (size(beq,2)~=1) then
+ errmsg = msprintf(gettext("%s: Constraint should be a vector"), "linprog");
+ error(errmsg);
+ end
+ end
+
+ for i = 1:nbConInEq
+ if (b(i) == -%inf)
+ errmsg = msprintf(gettext("%s: Value of b can not be negative infinity"), "linprog");
+ error(errmsg);
+ end
+ end
+
+ for i = 1:nbConEq
+ if (beq(i) == -%inf)
+ errmsg = msprintf(gettext("%s: Value of beq can not be negative infinity"), "linprog");
+ error(errmsg);
+ end
+ end
+
+ lb = lb(:);
+ ub = ub(:)
+ b = b(:);
+ beq = beq(:);
+ nbVar = size(c,1);
+ c = c';
+ conMatrix = [Aeq;A];
+ nbCon = size(conMatrix,1);
+ conlb = [beq; repmat(-%inf,nbConInEq,1)];
+ conub = [beq;b];
+
+ [xopt,fopt,status,iter,Zl,dual] = linearprog(nbVar,nbCon,c,conMatrix,conlb,conub,lb',ub',options);
+
+ xopt = xopt';
+ exitflag = status;
+ output = struct("Iterations" , [],..
+ "constrviolation" , []);
+
+ output.Iterations = iter;
+ output.constrviolation = max([0;norm(Aeq*xopt-beq, 'inf');(lb-xopt);(xopt-ub);(A*xopt-b)]);
+ lambda = struct("reduced_cost" , [], ..
+ "ineqlin" , [], ..
+ "eqlin" , []);
+
+ lambda.reduced_cost = Zl;
+ lambda.eqlin = dual(1:nbConEq);
+ lambda.ineqlin = dual(nbConEq+1:nbCon);
+ select status
+
+ case 0 then
+ printf("\nOptimal Solution.\n");
+ case 1 then
+ printf("\nPrimal Infeasible.\n");
+ case 2 then
+ printf("\nDual Infeasible.\n");
+ case 3 then
+ printf("\nIteration limit reached.\n");
+ case 4 then
+ printf("\nNumerical Difficulties.\n");
+ case 5 then
+ printf("\nPrimal Objective limit reached.\n");
+ case 6 then
+ printf("\nDual Objective limit reached.\n");
+ else
+ printf("\nInvalid status returned. Notify the Toolbox authors\n");
+ break;
+ end
+
+endfunction
diff --git a/macros/mps_linprog.bin b/macros/mps_linprog.bin
new file mode 100644
index 0000000..ee7d822
--- /dev/null
+++ b/macros/mps_linprog.bin
Binary files differ
diff --git a/macros/mps_linprog.sci b/macros/mps_linprog.sci
new file mode 100644
index 0000000..55f3edf
--- /dev/null
+++ b/macros/mps_linprog.sci
@@ -0,0 +1,90 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Bhanu Priya Sayal, Guru Pradeep Reddy
+// Organization: FOSSEE, IIT Bombay
+// Email:bhanupriyasayal@gmail.com,gurupradeept@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
+
+
+function [xopt,fopt,exitflag,output,lambda] =mps_linprog(varargin)
+
+ //To check the number of input and output argument
+ [lhs , rhs] = argn();
+
+ //To check the number of argument given by user
+ if ( rhs < 1 | rhs > 2) then
+ errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [1 2]"),"linprog",rhs);
+ error(errmsg)
+ end
+ mpsFile = varargin(1);
+
+ [sizeFile isFile] = fileinfo(mpsFile);
+ if(isFile ~= 0) then
+ errmsg = msprintf(gettext("%s: File is not present at the given location"),"linprog",rhs);
+ error(errmsg)
+ end
+
+ if ( rhs<2 | size(varargin(2)) ==0 ) then
+ param = list();
+ else
+ param =varargin(2);
+ end
+
+ if (type(param) ~= 15) then
+ errmsg = msprintf(gettext("%s: options should be a list "), "mps_linprog");
+ error(errmsg);
+ end
+
+ if (modulo(size(param),2)) then
+ errmsg = msprintf(gettext("%s: Size of parameters should be even"), "mps_linprog");
+ error(errmsg);
+ end
+ options = list("MaxIter" , [3000],);
+
+ for i = 1:(size(param))/2
+ select param(2*i-1)
+ case "MaxIter" then
+ options(2*i) = param(2*i);
+ end
+ end
+ //Calling the function by passing the required parameters
+
+ [xopt,fopt,status,iter,Zl,dual] = rmps(mpsFile,options);
+
+ xopt = xopt';
+ fopt=fopt;
+ exitflag = status;
+ output = struct("Iterations" , []);
+ output.Iterations = iter;
+ lambda = struct("reduced_cost" , [], ..
+ "dual" ,[]);
+
+ lambda.reduced_cost = Zl;
+ lambda.dual =dual;
+
+ select status
+
+ case 0 then
+ printf("\nOptimal Solution.\n");
+ case 1 then
+ printf("\nPrimal Infeasible.\n");
+ case 2 then
+ printf("\nDual Infeasible.\n");
+ case 3 then
+ printf("\nIteration limit reached.\n");
+ case 4 then
+ printf("\nNumerical Difficulties.\n");
+ case 5 then
+ printf("\nPrimal Objective limit reached.\n");
+ case 6 then
+ printf("\nDual Objective limit reached.\n");
+ else
+ printf("\nInvalid status returned. Notify the Toolbox authors\n");
+ break;
+ end
+
+endfunction
diff --git a/macros/names b/macros/names
index e04f783..1055c2a 100644
--- a/macros/names
+++ b/macros/names
@@ -1,5 +1,19 @@
+fgoalattain
+fgoalattainFunctions
+fminbnd
+fmincon
+fminimax
+fminimaxCheckdims
+fminimaxChecklhs
+fminimaxCheckrhs
+fminimaxChecktype
+fminimaxCheckvector
+fminunc
+linprog
lsqlin
lsqnonneg
+matrix_linprog
+mps_linprog
qpipopt
qpipoptmat
setOptions
diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin
index 64e0b44..58424ec 100644
--- a/macros/qpipoptmat.bin
+++ b/macros/qpipoptmat.bin
Binary files differ
diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci
index b74c718..ca32f8e 100644
--- a/macros/qpipoptmat.sci
+++ b/macros/qpipoptmat.sci
@@ -145,6 +145,10 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
f = varargin(2);
nbVar = size(H,1);
+ if(nbVar == 0) then
+ errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"), "qpipoptmat");
+ error(errmsg);
+ end
if ( rhs<3 ) then
A = []
@@ -424,5 +428,4 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
break;
end
-
endfunction
diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin
index ec35ee2..a5e68ab 100644
--- a/macros/symphonymat.bin
+++ b/macros/symphonymat.bin
Binary files differ
diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci
index 2d51b84..3848850 100644
--- a/macros/symphonymat.sci
+++ b/macros/symphonymat.sci
@@ -193,12 +193,16 @@ function [xopt,fopt,status,iter] = symphonymat (varargin)
A = varargin(3)
b = varargin(4)
+ if(size(c,2) == 0) then
+ errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"),"Symphonymat");
+ error(errmsg);
+ end
+
if (size(c,2)~=1) then
errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "Symphonymat");
error(errmsg);
end
-
nbVar = size(c,1);
if ( rhs<5 ) then
diff --git a/sci_gateway/cpp/LinCLP.hpp b/sci_gateway/cpp/LinCLP.hpp
new file mode 100755
index 0000000..90964f4
--- /dev/null
+++ b/sci_gateway/cpp/LinCLP.hpp
@@ -0,0 +1,82 @@
+/*
+ * Linear Solver Toolbox for Scilab using CLP library
+ * Authors :
+ Guru Pradeep Reddy
+ Bhanu Priya Sayal
+
+* Optimizing (minimizing) the linear objective function having any number of
+ variables and linear constraints(equality/inequality).
+ *
+*/
+
+#ifndef __LinCLP_HPP__
+#define __LinCLP_HPP__
+
+#include"OsiSolverInterface.hpp"
+#include "OsiClpSolverInterface.hpp"
+#include "CoinPackedMatrix.hpp"
+#include "CoinPackedVector.hpp"
+
+class LinCLP
+{
+ private:
+
+ int numVars_; //Number of variables
+
+ int numCons_; //Number of inequality constraints
+
+ double* objMatrix_[]; //Objective function vector
+
+ double* conMatrix_[]; //Inequality constraint matrix
+
+ double* conlb_[]; //Inequality constraint vector
+
+ double* conub_[]; //Equality constraint vector
+
+ double* lb_[]; //Lower bounds for all variables
+
+ double* ub_[]; //Upper bounds for all variables
+
+ double options_[]; //options for setting maximum iterations and writing mps and lp files
+
+ double* xValue_ = NULL; //Optimal value of variables
+
+ double objValue_ =0 ; //Optimal values of objective
+
+ double status_ = 0; //Return Status
+
+ double iterations_ = 0; //Number of iteration
+
+ double* reducedCost_ = NULL; //Reduced cost
+
+ double* dual_ = NULL; // Dual of the solution
+
+
+ public:
+/*
+ * Constructor
+*/
+ LinCLP(int numVars_ , int numCons_ ,double objMatrix_[] , double conMatrix_[] , double conlb_[] , double conub_[] ,double lb_[] , double ub_[], double options_[]);
+
+
+ virtual ~LinCLP(); //Destructor to free memory
+
+ const double* getX(); //Returns a pointer to matrix of size
+ //1*numVars with final values for the objective variables
+
+ double getObjVal(); //Returns the output of the final value of the objective
+
+ int returnStatus(); //Returns the status of the problem
+
+ double iterCount(); //Returns the iteration count
+
+ const double* getReducedCost(); //Returns a pointer to matrix of size
+ //1*numVars with values for lower dual vector
+
+ double* getDual(); //Returns a pointer to matrix of size
+ //1*numCons with values for dual vector
+
+};
+
+#endif __LinCLP_HPP__
+
diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce b/sci_gateway/cpp/builder_gateway_cpp.sce
index 6e4adf7..3503996 100644
--- a/sci_gateway/cpp/builder_gateway_cpp.sce
+++ b/sci_gateway/cpp/builder_gateway_cpp.sce
@@ -1,13 +1,13 @@
// Copyright (C) 2015 - IIT Bombay - FOSSEE
//
+// Author: Keyur Joshi, Sai Kiran, Iswarya and Harpreet Singh
+// Organization: FOSSEE, IIT Bombay
+// Email: harpreet.mertia@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
-// Author: Harpreet Singh
-// Organization: FOSSEE, IIT Bombay
-// Email: toolbox@scilab.in
mode(-1)
lines(0)
@@ -21,9 +21,9 @@ path_builder = get_absolute_file_path('builder_gateway_cpp.sce');
tools_path = path_builder + "../../thirdparty/linux/";
-C_Flags=["-w -fpermissive -I"+tools_path+"include/coin -Wl,-rpath="+tools_path+"lib/"+Version+filesep()+" "]
+C_Flags=["-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -fpermissive -I"+tools_path+"include/coin -Wl,-rpath="+tools_path+"lib/"+Version+filesep()+" "]
-Linker_Flag = ["-L"+tools_path+"lib/"+Version+filesep()+"libSym"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libipopt" ]
+Linker_Flag = ["-L"+tools_path+"lib/"+Version+filesep()+"libSym"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libipopt"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libClp"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libOsiClp"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libCoinUtils" ]
//Name of All the Functions
@@ -108,8 +108,17 @@ Function_Names = [
"sym_getIterCount","sci_sym_get_iteration_count";
"sym_getConstrActivity","sci_sym_getRowActivity";
+ //Linprog function
+ "linearprog","sci_linearprog"
+ "rmps","sci_rmps"
+
//QP function
"solveqp","sci_solveqp"
+
+ //fminunc function and fminbnd function
+ "solveminuncp","sci_solveminuncp"
+ "solveminbndp","sci_solveminbndp"
+ "solveminconp","sci_solveminconp"
];
//Name of all the files to be compiled
@@ -140,8 +149,21 @@ Files = [
"sci_sym_remove.cpp",
"sci_QuadNLP.cpp",
"QuadNLP.hpp",
- "sci_ipopt.cpp"
-
+ "sci_ipopt.cpp",
+ "minuncNLP.hpp",
+ "sci_minuncNLP.cpp",
+ "sci_ipoptfminunc.cpp",
+ "minbndNLP.hpp",
+ "sci_minbndNLP.cpp",
+ "sci_ipoptfminbnd.cpp",
+ "minconNLP.hpp",
+ "sci_minconNLP.cpp",
+ "sci_ipoptfmincon.cpp",
+ "sci_ipopt.cpp",
+ "sci_LinProg.cpp",
+ "sci_LinCLP.cpp",
+ "LinCLP.hpp",
+ "read_mps.cpp"
]
tbx_build_gateway(toolbox_title,Function_Names,Files,get_absolute_file_path("builder_gateway_cpp.sce"), [], Linker_Flag, C_Flags, [], "g++");
diff --git a/sci_gateway/cpp/libFAMOS.c b/sci_gateway/cpp/libFAMOS.c
index 61990ad..d7911de 100644
--- a/sci_gateway/cpp/libFAMOS.c
+++ b/sci_gateway/cpp/libFAMOS.c
@@ -64,7 +64,12 @@ extern Gatefunc sci_sym_getVarSoln;
extern Gatefunc sci_sym_getObjVal;
extern Gatefunc sci_sym_get_iteration_count;
extern Gatefunc sci_sym_getRowActivity;
+extern Gatefunc sci_linearprog;
+extern Gatefunc sci_rmps;
extern Gatefunc sci_solveqp;
+extern Gatefunc sci_solveminuncp;
+extern Gatefunc sci_solveminbndp;
+extern Gatefunc sci_solveminconp;
static GenericTable Tab[]={
{(Myinterfun)sci_gateway,sci_sym_open,"sym_open"},
{(Myinterfun)sci_gateway,sci_sym_close,"sym_close"},
@@ -124,7 +129,12 @@ static GenericTable Tab[]={
{(Myinterfun)sci_gateway,sci_sym_getObjVal,"sym_getObjVal"},
{(Myinterfun)sci_gateway,sci_sym_get_iteration_count,"sym_getIterCount"},
{(Myinterfun)sci_gateway,sci_sym_getRowActivity,"sym_getConstrActivity"},
+ {(Myinterfun)sci_gateway,sci_linearprog,"linearprog"},
+ {(Myinterfun)sci_gateway,sci_rmps,"rmps"},
{(Myinterfun)sci_gateway,sci_solveqp,"solveqp"},
+ {(Myinterfun)sci_gateway,sci_solveminuncp,"solveminuncp"},
+ {(Myinterfun)sci_gateway,sci_solveminbndp,"solveminbndp"},
+ {(Myinterfun)sci_gateway,sci_solveminconp,"solveminconp"},
};
int C2F(libFAMOS)()
diff --git a/sci_gateway/cpp/libFAMOS.so b/sci_gateway/cpp/libFAMOS.so
index 4ab40e5..c8462c6 100755
--- a/sci_gateway/cpp/libFAMOS.so
+++ b/sci_gateway/cpp/libFAMOS.so
Binary files differ
diff --git a/sci_gateway/cpp/loader.sce b/sci_gateway/cpp/loader.sce
index fe1d630..37305c7 100644
--- a/sci_gateway/cpp/loader.sce
+++ b/sci_gateway/cpp/loader.sce
@@ -68,7 +68,12 @@ list_functions = [ 'sym_open';
'sym_getObjVal';
'sym_getIterCount';
'sym_getConstrActivity';
+ 'linearprog';
+ 'rmps';
'solveqp';
+ 'solveminuncp';
+ 'solveminbndp';
+ 'solveminconp';
];
addinter(libFAMOS_path + filesep() + 'libFAMOS' + getdynlibext(), 'libFAMOS', list_functions);
// remove temp. variables on stack
diff --git a/sci_gateway/cpp/minbndNLP.hpp b/sci_gateway/cpp/minbndNLP.hpp
new file mode 100644
index 0000000..17d5a7e
--- /dev/null
+++ b/sci_gateway/cpp/minbndNLP.hpp
@@ -0,0 +1,116 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#ifndef __minbndNLP_HPP__
+#define __minbndNLP_HPP__
+#include "IpTNLP.hpp"
+
+using namespace Ipopt;
+
+class minbndNLP : public TNLP
+{
+ private:
+
+ Index numVars_; //Number of input variables
+
+ Index numConstr_; //Number of constraints
+
+ Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*1
+ //with final value for the primal variable.
+
+ Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_
+ // with final values for the lower bound multipliers
+
+ Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_
+ // with final values for the upper bound multipliers
+
+ Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
+
+ int iter_; //Number of iteration.
+
+ int status_; //Solver return status
+
+
+ const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*1
+ // with upper bounds of all variable.
+
+ const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*1
+ // with lower bounds of all variable.
+
+ minbndNLP(const minbndNLP&);
+ minbndNLP& operator=(const minbndNLP&);
+
+ public:
+
+ /** user defined constructor */
+ minbndNLP(Index nV, Index nC,Number *LB,Number *UB):numVars_(nV),numConstr_(nC),finalX_(0),finalZl_(0), finalZu_(0),varLB_(LB),varUB_(UB),finalObjVal_(1e20){ }
+
+ /** default destructor */
+ virtual ~minbndNLP();
+
+ /** Method to return some info about the nlp */
+ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
+ Index& nnz_h_lag, IndexStyleEnum& index_style);
+
+ /** Method to return the bounds for my problem */
+ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
+ Index m, Number* g_l, Number* g_u);
+
+ /** Method to return the starting point for the algorithm */
+ virtual bool get_starting_point(Index n, bool init_x, Number* x,
+ bool init_z, Number* z_L, Number* z_U,
+ Index m, bool init_lambda,
+ Number* lambda);
+
+ /** Method to return the objective value */
+ virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
+
+ /** Method to return the gradient of the objective */
+ virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
+
+ /** Method to return the constraint residuals */
+ virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
+
+ /** Method to return:
+ * 1) The structure of the jacobian (if "values" is NULL)
+ * 2) The values of the jacobian (if "values" is not NULL)
+ */
+ virtual bool eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values);
+
+ /** Method to return:
+ * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
+ * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
+ */
+ virtual bool eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values);
+
+ /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
+ virtual void finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda,Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq);
+
+ const double * getX(); //Returns a pointer to a matrix of size of 1*1
+ //with final value for the primal variable.
+
+ const double * getZl(); //Returns a pointer to a matrix of size of 1*numVars_
+ // with final values for the lower bound multipliers
+
+ const double * getZu(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final values for the upper bound multipliers
+
+ double getObjVal(); //Returns the output of the final value of the objective.
+
+ double iterCount(); //Returns the iteration count
+
+ int returnStatus(); //Returns the status count
+
+};
+
+
+#endif
diff --git a/sci_gateway/cpp/minconNLP.hpp b/sci_gateway/cpp/minconNLP.hpp
new file mode 100644
index 0000000..df496ce
--- /dev/null
+++ b/sci_gateway/cpp/minconNLP.hpp
@@ -0,0 +1,173 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#ifndef __minconNLP_HPP__
+#define __minconNLP_HPP__
+#include "IpTNLP.hpp"
+
+using namespace Ipopt;
+
+class minconNLP : public TNLP
+{
+ private:
+
+ Index numVars_; //Number of input variables
+
+ Index numConstr_; //Number of constraints
+
+ Number flag1_; //Gradient of objective ON or OFF
+
+ Number flag2_; //Hessian of objective ON or OFF
+
+ Number flag3_; //Jacobian of constraints ON or OFF
+
+ Number nonlinCon_; //Number of non-linear constraints
+
+ Number nonlinIneqCon_; //Number of non-linear inequality constraints
+
+ const Number *A_= NULL; //Matrix for linear inequality constraints
+
+ const Number *b_= NULL; //Matrix for bounds of linear inequality constraints
+
+ const Number *Aeq_= NULL; //Matrix for linear equality constraints
+
+ const Number *beq_= NULL; //Matrix for bounds of linear equality constraints
+
+ Index Arows_; //Number of rows of linear inequality constraints
+
+ Index Acols_; //Number of columns of linear inequality constraints
+
+ Index brows_; //Number of rows of bounds of linear inequality constraints
+
+ Index bcols_; //Number of columns of bounds of linear inequality constraints
+
+ Index Aeqrows_; //Number of rows of linear equality constraints
+
+ Index Aeqcols_; //Number of columns of linear equality constraints
+
+ Index beqrows_; //Number of rows of bounds of linear equality constraints
+
+ Index beqcols_; //Number of columns of bounds of linear equality constraints
+
+
+ const Number *varGuess_= NULL; //varGuess_ is a pointer to a matrix of size of 1*numVars_
+ //with initial guess of all variables.
+
+ const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*numVar_
+ // with upper bounds of all variables.
+
+ const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*numVar_
+ // with lower bounds of all variables.
+
+ Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_
+ // with final values for the lower bound multipliers
+
+ Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_
+ // with final values for the upper bound multipliers
+
+ Number *finalLambda_= NULL; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_
+ // with final values for the upper bound multipliers
+
+ Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVars_
+ //with final value for the primal variables.
+
+ Number *finalGradient_=NULL; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_
+ //with final value of gradient for the primal variables.
+
+
+ Number *finalHessian_=NULL; //finalHessian_ is a pointer to a matrix of size of 1*numVar_
+ //with final value of hessian for the primal variables.
+
+
+ Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
+
+ int iter_; //Number of iteration.
+
+ int status_; //Solver return status
+
+
+ minconNLP(const minconNLP&);
+ minconNLP& operator=(const minconNLP&);
+
+ public:
+
+ /** user defined constructor */
+ minconNLP(Index nV, Index nC, Number *x0 ,Number *A, Number *b, Number* Aeq, Number *beq, Index Arows, Index Acols, Index brows, Index bcols, Index Aeqrows, Index Aeqcols, Index beqrows, Index beqcols, Number* LB, Number* UB, Number nlC, Number nlIC, Number f1, Number f2, Number f3) : numVars_(nV), numConstr_(nC), varGuess_(x0), A_(A), b_(b), Aeq_(Aeq), beq_(beq), Arows_(Arows), Acols_(Acols), brows_(brows), bcols_(bcols), Aeqrows_(Aeqrows), Aeqcols_(Aeqcols), beqrows_(beqrows), beqcols_(beqcols), varLB_(LB), varUB_(UB), nonlinCon_(nlC), nonlinIneqCon_(nlIC), flag1_(f1), flag2_(f2), flag3_(f3), finalX_(0), finalZl_(0), finalZu_(0), finalGradient_(0), finalHessian_(0), finalObjVal_(1e20){ }
+
+ /** default destructor */
+ virtual ~minconNLP();
+
+ /** Method to return some info about the nlp */
+ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
+ Index& nnz_h_lag, IndexStyleEnum& index_style);
+
+ /** Method to return the bounds for my problem */
+ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
+ Index m, Number* g_l, Number* g_u);
+
+ /** Method to return the starting point for the algorithm */
+ virtual bool get_starting_point(Index n, bool init_x, Number* x,
+ bool init_z, Number* z_L, Number* z_U,
+ Index m, bool init_lambda,
+ Number* lambda);
+
+ /** Method to return the objective value */
+ virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
+
+ /** Method to return the gradient of the objective */
+ virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
+
+ /** Method to return the constraint residuals */
+ virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
+
+ /** Method to return:
+ * 1) The structure of the jacobian (if "values" is NULL)
+ * 2) The values of the jacobian (if "values" is not NULL)
+ */
+ virtual bool eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values);
+
+ /** Method to return:
+ * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
+ * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
+ */
+ virtual bool eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values);
+
+ /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
+ virtual void finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda,Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq);
+
+ const double * getX(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final value for the primal variables.
+
+ const double * getGrad(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final value of gradient for the primal variables.
+
+ const double * getHess(); //Returns a pointer to a matrix of size of numVars_*numVars_
+ //with final value of hessian for the primal variables.
+
+ const double * getZl(); //Returns a pointer to a matrix of size of 1*numVars_
+ // with final values for the lower bound multipliers
+
+ const double * getZu(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final values for the upper bound multipliers
+
+ const double * getLambda(); //Returns a pointer to a matrix of size of 1*numConstr_
+ //with final values for the constraint multipliers
+
+ double getObjVal(); //Returns the output of the final value of the objective.
+
+ double iterCount(); //Returns the iteration count
+
+ int returnStatus(); //Returns the status count
+
+};
+
+#endif
diff --git a/sci_gateway/cpp/minuncNLP.hpp b/sci_gateway/cpp/minuncNLP.hpp
new file mode 100644
index 0000000..70910e5
--- /dev/null
+++ b/sci_gateway/cpp/minuncNLP.hpp
@@ -0,0 +1,113 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#ifndef __minuncNLP_HPP__
+#define __minuncNLP_HPP__
+#include "IpTNLP.hpp"
+
+using namespace Ipopt;
+
+class minuncNLP : public TNLP
+{
+ private:
+
+ Index numVars_; //Number of input variables
+
+ Index numConstr_; //Number of constraints
+
+ Number flag1_; //Used for Gradient On/OFF
+
+ Number flag2_; //Used for Hessian ON/OFF
+
+ const Number *varGuess_= NULL; //varGuess_ is a pointer to a matrix of size of 1*numVars_ with initial guess of all variables.
+
+ Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVars_ with final value for the primal variables.
+
+ Number *finalGradient_=NULL; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_ with final value of gradient for the primal variables.
+
+ Number *finalHessian_=NULL; //finalHessian_ is a pointer to a matrix of size of 1*numVar_ with final value of hessian for the primal variables.
+
+ Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
+
+ int iter_; //Number of iteration.
+
+ int status_; //Solver return status
+
+
+ minuncNLP(const minuncNLP&);
+ minuncNLP& operator=(const minuncNLP&);
+
+ public:
+
+ /** user defined constructor */
+ minuncNLP(Index nV, Index nC,Number *x0,Number f1, Number f2):numVars_(nV),numConstr_(nC),varGuess_(x0),flag1_(f1),flag2_(f2),finalX_(0),finalGradient_(0),finalHessian_(0),finalObjVal_(1e20){ }
+
+ /** default destructor */
+ virtual ~minuncNLP();
+
+ /** Method to return some info about the nlp */
+ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
+ Index& nnz_h_lag, IndexStyleEnum& index_style);
+
+ /** Method to return the bounds for my problem */
+ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
+ Index m, Number* g_l, Number* g_u);
+
+ /** Method to return the starting point for the algorithm */
+ virtual bool get_starting_point(Index n, bool init_x, Number* x,
+ bool init_z, Number* z_L, Number* z_U,
+ Index m, bool init_lambda,
+ Number* lambda);
+
+ /** Method to return the objective value */
+ virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
+
+ /** Method to return the gradient of the objective */
+ virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
+
+ /** Method to return the constraint residuals */
+ virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
+
+ /** Method to return:
+ * 1) The structure of the jacobian (if "values" is NULL)
+ * 2) The values of the jacobian (if "values" is not NULL)
+ */
+ virtual bool eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values);
+
+ /** Method to return:
+ * 1) The structure of the hessian of the lagrangian (if "values" is NULL)
+ * 2) The values of the hessian of the lagrangian (if "values" is not NULL)
+ */
+ virtual bool eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values);
+
+ /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
+ virtual void finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda,Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq);
+
+ const double * getX(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final value for the primal variables.
+
+ const double * getGrad(); //Returns a pointer to a matrix of size of 1*numVars_
+ //with final value of gradient for the primal variables.
+
+ const double * getHess(); //Returns a pointer to a matrix of size of numVars_*numVars_
+ //with final value of hessian for the primal variables.
+
+ double getObjVal(); //Returns the output of the final value of the objective.
+
+ double iterCount(); //Returns the iteration count
+
+ int returnStatus(); //Returns the status count
+
+};
+
+
+#endif
diff --git a/sci_gateway/cpp/read_mps.cpp b/sci_gateway/cpp/read_mps.cpp
new file mode 100644
index 0000000..31f71b8
--- /dev/null
+++ b/sci_gateway/cpp/read_mps.cpp
@@ -0,0 +1,113 @@
+/*
+ * Linear Solver Toolbox for Scilab using CLP library
+ * Authors :
+ Guru Pradeep Reddy
+ Bhanu Priya Sayal
+*/
+
+#include "sci_iofunc.hpp"
+#include "OsiClpSolverInterface.hpp"
+
+extern "C"{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <iostream>
+
+//Solver function
+int sci_rmps(char *fname)
+{
+ //creating a problem pointer using base class of OsiSolverInterface and
+ //instantiate the object using derived class of ClpSolverInterface
+ OsiSolverInterface* si = new OsiClpSolverInterface();
+
+ // Error management variable
+ SciErr sciErr;
+
+ //data declarations
+ int *piAddressVarOne = NULL; //pointer used to access argument of the function
+ char* ptr; //pointer to point to address of file name
+ double* options_; //options to set maximum iterations
+ CheckInputArgument(pvApiCtx, 2,2 ); //Check we have exactly two arguments as input or not
+ CheckOutputArgument(pvApiCtx, 6, 6); //Check we have exactly six arguments on output side or not
+ //Getting the input arguments from Scilab
+ //Getting the MPS file path
+ //Reading mps file
+ getStringFromScilab(1,&ptr);
+
+ std::cout<<ptr;
+
+ //get options from Scilab
+ if(getFixedSizeDoubleMatrixInList(2 , 2 , 1 , 1 , &options_))
+ {
+ return 1;
+ }
+
+ //Read the MPS file
+ si->readMps(ptr);
+
+ //setting options for maximum iterations
+ si->setIntParam(OsiMaxNumIteration,options_[0]);
+
+ //Solve the problem
+ si->initialSolve();
+
+ //Quering about the problem
+ //get number of variables
+ double numVars_;
+ numVars_ = si->getNumCols();
+
+ //get number of constraint equations
+ double numCons_;
+ numCons_ = si->getNumRows();
+
+ //Output the solution to Scilab
+ //get solution for x
+ const double* xValue = si->getColSolution();
+
+ //get objective value
+ double objValue = si->getObjValue();
+
+ //get Status value
+ double status;
+ if(si->isProvenOptimal())
+ status=0;
+ else if(si->isProvenPrimalInfeasible())
+ status=1;
+ else if(si->isProvenDualInfeasible())
+ status=2;
+ else if(si->isIterationLimitReached())
+ status=3;
+ else if(si->isAbandoned())
+ status=4;
+ else if(si->isPrimalObjectiveLimitReached())
+ status=5;
+ else if(si->isDualObjectiveLimitReached())
+ status=6;
+
+ //get number of iterations
+ double iterations = si->getIterationCount();
+
+ //get reduced cost
+ const double* reducedCost = si->getReducedCost();
+
+ //get dual vector
+ const double* dual = si->getRowPrice();
+
+ returnDoubleMatrixToScilab(1 , 1 , numVars_ , xValue);
+ returnDoubleMatrixToScilab(2 , 1 , 1 , &objValue);
+ returnDoubleMatrixToScilab(3 , 1 , 1 , &status);
+ returnDoubleMatrixToScilab(4 , 1 , 1 , &iterations);
+ returnDoubleMatrixToScilab(5 , 1 , numVars_ , reducedCost);
+ returnDoubleMatrixToScilab(6 , 1 , numCons_ , dual);
+
+ free(xValue);
+ free(dual);
+ free(reducedCost);
+}
+}
+
+
+
+
diff --git a/sci_gateway/cpp/sci_LinCLP.cpp b/sci_gateway/cpp/sci_LinCLP.cpp
new file mode 100644
index 0000000..7996bfc
--- /dev/null
+++ b/sci_gateway/cpp/sci_LinCLP.cpp
@@ -0,0 +1,119 @@
+/*
+ * Linear Solver Toolbox for Scilab using CLP library
+ * Authors :
+ Guru Pradeep Reddy
+ Bhanu Priya Sayal
+*/
+
+#include "LinCLP.hpp"
+extern "C"{
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "sci_iofunc.hpp"
+
+//creating a problem pointer using Base class of OsiSolverInterface and
+//Instantiate the object using specific derived class of ClpSolver
+OsiSolverInterface* si = new OsiClpSolverInterface();
+
+LinCLP::~LinCLP()
+ {
+ free(objMatrix_);
+ free(conMatrix_);
+ free(conlb_);
+ free(conub_);
+ free(lb_);
+ free(ub_);
+ free(xValue_);
+ free(reducedCost_);
+ free(dual_);}
+
+//Clp Solver function definition
+LinCLP::LinCLP(int numVars_ , int numCons_ ,double objMatrix_[] , double conMatrix_[] , double conlb_[] , double conub_[] ,double lb_[] , double ub_[], double options_[])
+{
+
+ //Defining the constraint matrix
+ CoinPackedMatrix *matrix = new CoinPackedMatrix(false , 0 , 0);
+ matrix->setDimensions(0 , numVars_);
+ for(int i=0 ; i<numCons_ ; i++)
+ {
+ CoinPackedVector row;
+ for(int j=0 ; j<numVars_ ; j++)
+ {
+ row.insert(j, conMatrix_[i+j*numCons_]);
+ }
+
+ matrix->appendRow(row);
+ }
+
+ //setting options for maximum iterations
+ si->setIntParam(OsiMaxNumIteration,options_[0]);
+
+ //Load the problem to OSI
+ si->loadProblem(*matrix , lb_ , ub_, objMatrix_ , conlb_ , conub_);
+
+ //Solve the problem
+ si->initialSolve();
+
+}
+
+ //Output the solution to Scilab
+ //get solution for x
+ const double* LinCLP::getX()
+ {
+ xValue_ = si->getColSolution();
+ return xValue_;
+ }
+
+ //get objective value
+ double LinCLP::getObjVal()
+ {
+ objValue_ = si->getObjValue();
+ return objValue_;
+ }
+
+ //get exit status
+ int LinCLP::returnStatus()
+ {
+ status_;
+ if(si->isProvenOptimal())
+ status_=0;
+ else if(si->isProvenPrimalInfeasible())
+ status_=1;
+ else if(si->isProvenDualInfeasible())
+ status_=2;
+ else if(si->isIterationLimitReached())
+ status_=3;
+ else if(si->isAbandoned())
+ status_=4;
+ else if(si->isPrimalObjectiveLimitReached())
+ status_=5;
+ else if(si->isDualObjectiveLimitReached())
+ status_=6;
+ return status_;
+ }
+
+ //get number of iterations
+ double LinCLP::iterCount()
+ {
+ iterations_ = si->getIterationCount();
+ return iterations_;
+ }
+
+ //get lower vector
+ const double* LinCLP::getReducedCost()
+ {
+ reducedCost_ = si->getReducedCost();
+ return reducedCost_;
+ }
+
+ //get dual vector
+ double* LinCLP::getDual()
+ {
+ dual_ = si->getRowPrice();
+ return dual_;
+ }
+
+}
+
diff --git a/sci_gateway/cpp/sci_LinProg.cpp b/sci_gateway/cpp/sci_LinProg.cpp
new file mode 100644
index 0000000..8a4ec25
--- /dev/null
+++ b/sci_gateway/cpp/sci_LinProg.cpp
@@ -0,0 +1,150 @@
+/*
+ * Linear Solver Toolbox for Scilab using CLP library
+ * Authors :
+ Guru Pradeep Reddy
+ Bhanu Priya Sayal
+*/
+
+#include "sci_iofunc.hpp"
+#include "LinCLP.hpp"
+
+extern "C"{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <localization.h>
+#include <sciprint.h>
+
+//Solver function
+int sci_linearprog(char *fname)
+{
+ //Objective function
+ double* obj;
+ //Constraint matrix coefficients
+ double* conMatrix;
+ //Constraints upper bound
+ double* conlb;
+ //Constraints lower bound
+ double* conub;
+ //Lower bounds for variables
+ double* lb;
+ //Upper bounds for variables
+ double* ub;
+ //options for maximum iterations and writing mps
+ double* options;
+ //Flag for Mps
+ double flagMps;
+ //mps file path
+ char * mpsFile;
+ //Error structure in Scilab
+ SciErr sciErr;
+ //Number of rows and columns in objective function
+ int nVars=0, nCons=0,temp1=0,temp2=0;
+
+ CheckInputArgument(pvApiCtx , 9 , 9); //Checking the input arguments
+ CheckOutputArgument(pvApiCtx , 6, 6); //Checking the output arguments
+
+ ////////// Manage the input argument //////////
+
+ //Number of Variables
+ if(getIntFromScilab(1,&nVars))
+ {
+ return 1;
+ }
+
+ //Number of Constraints
+ if (getIntFromScilab(2,&nCons))
+ {
+ return 1;
+ }
+
+ //Objective function from Scilab
+ temp1 = nVars;
+ temp2 = nCons;
+ if (getFixedSizeDoubleMatrixFromScilab(3,1,temp1,&obj))
+ {
+ return 1;
+ }
+
+ if (nCons!=0)
+ {
+ //conMatrix matrix from scilab
+ temp1 = nCons;
+ temp2 = nVars;
+
+ if (getFixedSizeDoubleMatrixFromScilab(4,temp1,temp2,&conMatrix))
+ {
+ return 1;
+ }
+
+ //conLB matrix from scilab
+ temp1 = nCons;
+ temp2 = 1;
+ if (getFixedSizeDoubleMatrixFromScilab(5,temp1,temp2,&conlb))
+ {
+ return 1;
+ }
+
+ //conUB matrix from scilab
+ if (getFixedSizeDoubleMatrixFromScilab(6,temp1,temp2,&conub))
+ {
+ return 1;
+ }
+
+ }
+
+ //lb matrix from scilab
+ temp1 = 1;
+ temp2 = nVars;
+ if (getFixedSizeDoubleMatrixFromScilab(7,temp1,temp2,&lb))
+ {
+ return 1;
+ }
+
+
+ //ub matrix from scilab
+ if (getFixedSizeDoubleMatrixFromScilab(8,temp1,temp2,&ub))
+ {
+ return 1;
+ }
+
+ //get options from scilab
+ if(getFixedSizeDoubleMatrixInList(9 , 2 , 1 , 1 , &options))
+ {
+ return 1;
+ }
+
+ //Call to the Clp Solver
+ LinCLP* Prob = new LinCLP(nVars,nCons,obj,conMatrix,conlb,conub,lb,ub,options);
+
+ //Output the solution to Scilab
+ //get solution for x
+ double* xValue = Prob->getX();
+
+ //get objective value
+ double objValue = Prob->getObjVal();
+
+ //get Status value
+ double status = Prob->returnStatus();
+
+ //get number of iterations
+ double iterations = Prob->iterCount();
+
+ //get reduced cost
+ double* reducedCost = Prob->getReducedCost();
+
+ //get dual vector
+ double* dual = Prob->getDual();
+
+ returnDoubleMatrixToScilab(1 , 1 , nVars , xValue);
+ returnDoubleMatrixToScilab(2 , 1 , 1 , &objValue);
+ returnDoubleMatrixToScilab(3 , 1 , 1 , &status);
+ returnDoubleMatrixToScilab(4 , 1 , 1 , &iterations);
+ returnDoubleMatrixToScilab(5 , 1 , nVars , reducedCost);
+ returnDoubleMatrixToScilab(6 , 1 , nCons , dual);
+
+ }
+}
+
+
+
+
diff --git a/sci_gateway/cpp/sci_iofunc.cpp b/sci_gateway/cpp/sci_iofunc.cpp
index e92c318..8dc2acf 100644
--- a/sci_gateway/cpp/sci_iofunc.cpp
+++ b/sci_gateway/cpp/sci_iofunc.cpp
@@ -1,14 +1,6 @@
-// Copyright (C) 2015 - IIT Bombay - FOSSEE
-//
-// 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
-// Author: Keyur Joshi, Harpreet Singh
-// Organization: FOSSEE, IIT Bombay
-// Email: toolbox@scilab.in
-
+// Symphony Toolbox for Scilab
+// (Definition of) Functions for input and output from Scilab
+// By Keyur Joshi
#include "api_scilab.h"
#include "Scierror.h"
@@ -16,6 +8,35 @@
#include "BOOL.h"
#include <localization.h>
+using namespace std;
+
+int getFunctionFromScilab(int argNum, int **dest)
+{
+ //data declarations
+ SciErr sciErr;
+ int iRet,*varAddress, iType;
+ double inputDouble;
+ const char errMsg[]="Wrong type for input argument #%d: A function is expected.\n";
+ const int errNum=999;
+ //get variable address
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, dest);
+ if(sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+ //check that the variable is necessarily a function
+ sciErr = getVarType(pvApiCtx, *dest, &iType);
+ if(sciErr.iErr || iType != sci_c_function)
+ {
+ Scierror(errNum,errMsg,argNum);
+ return 1;
+ }
+ return 0;
+
+}
+
+
int getDoubleFromScilab(int argNum, double *dest)
{
//data declarations
@@ -187,6 +208,29 @@ int getFixedSizeDoubleMatrixInList(int argNum, int itemPos, int rows, int cols,
printError(&sciErr, 0);
return 1;
}
+ return 0;
+}
+
+int getStringFromScilab(int argNum,char **dest)
+{
+ int *varAddress,inputMatrixRows,inputMatrixCols;
+ SciErr sciErr;
+ sciErr = getVarAddressFromPosition(pvApiCtx, argNum, &varAddress);
+
+ //check whether there is an error or not.
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+ if ( !isStringType(pvApiCtx,varAddress) )
+ {
+ Scierror(999,"Wrong type for input argument 1: A file name is expected.\n");
+ return 1;
+ }
+ //read the value in that pointer pointing to file name
+ getAllocatedSingleString(pvApiCtx, varAddress, dest);
+
}
int return0toScilab()
@@ -255,3 +299,4 @@ int returnIntegerMatrixToScilab(int itemPos, int rows, int cols, int *dest)
return 0;
}
+
diff --git a/sci_gateway/cpp/sci_iofunc.hpp b/sci_gateway/cpp/sci_iofunc.hpp
index fc379f4..2c84c82 100644
--- a/sci_gateway/cpp/sci_iofunc.hpp
+++ b/sci_gateway/cpp/sci_iofunc.hpp
@@ -1,25 +1,19 @@
-// Copyright (C) 2015 - IIT Bombay - FOSSEE
-//
-// 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
-// Author: Keyur Joshi, Harpreet Singh
-// Organization: FOSSEE, IIT Bombay
-// Email: toolbox@scilab.in
+// Symphony Toolbox for Scilab
+// (Declaration of) Functions for input and output from Scilab
+// By Keyur Joshi
#ifndef SCI_IOFUNCHEADER
#define SCI_IOFUNCHEADER
//input
+int getFunctionFromScilab(int argNum, int **dest);
int getDoubleFromScilab(int argNum, double *dest);
int getUIntFromScilab(int argNum, int *dest);
int getIntFromScilab(int argNum, int *dest);
int getFixedSizeDoubleMatrixFromScilab(int argNum, int rows, int cols, double **dest);
int getDoubleMatrixFromScilab(int argNum, int *rows, int *cols, double **dest);
int getFixedSizeDoubleMatrixInList(int argNum, int itemPos, int rows, int cols, double **dest);
-
+int getStringFromScilab(int argNum,char** dest);
//output
int return0toScilab();
diff --git a/sci_gateway/cpp/sci_ipoptfminbnd.cpp b/sci_gateway/cpp/sci_ipoptfminbnd.cpp
new file mode 100644
index 0000000..aa5addf
--- /dev/null
+++ b/sci_gateway/cpp/sci_ipoptfminbnd.cpp
@@ -0,0 +1,195 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "sci_iofunc.hpp"
+#include "IpIpoptApplication.hpp"
+#include "minbndNLP.hpp"
+#include <IpSolveStatistics.hpp>
+
+extern "C"
+{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <iostream>
+
+using namespace std;
+
+int sci_solveminbndp(char *fname)
+{
+ using namespace Ipopt;
+
+ CheckInputArgument(pvApiCtx, 5, 5);
+ CheckOutputArgument(pvApiCtx, 9, 9);
+
+ // Error management variable
+ SciErr sciErr;
+
+ //Function pointers,lower bound and upper bound pointers
+ int* funptr=NULL;
+ int* gradhesptr=NULL;
+ double* varLB=NULL;
+ double* varUB=NULL;
+
+ // Input arguments
+ double *cpu_time=NULL,*max_iter=NULL,*tol_val=NULL;
+ static unsigned int nVars = 0,nCons = 0;
+ unsigned int temp1 = 0,temp2 = 0, iret = 0;
+ int x1_rows, x1_cols, x2_rows, x2_cols;
+
+ // Output arguments
+ double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ double *fZl=NULL;
+ double *fZu=NULL;
+ double dual_inf, constr_viol, complementarity, kkt_error;
+ int rstatus = 0;
+ int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
+
+ ////////// Manage the input argument //////////
+
+ //Objective Function
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+
+ //Function for gradient and hessian
+ if(getFunctionFromScilab(2,&gradhesptr))
+ {
+ return 1;
+ }
+
+ //x1(lower bound) matrix from scilab
+ if(getDoubleMatrixFromScilab(3, &x1_rows, &x1_cols, &varLB))
+ {
+ return 1;
+ }
+
+ //x2(upper bound) matrix from scilab
+ if(getDoubleMatrixFromScilab(4, &x2_rows, &x2_cols, &varUB))
+ {
+ return 1;
+ }
+
+ //Getting number of iterations
+ if(getFixedSizeDoubleMatrixInList(5,2,temp1,temp2,&max_iter))
+ {
+ return 1;
+ }
+
+ //Getting Cpu Time
+ if(getFixedSizeDoubleMatrixInList(5,4,temp1,temp2,&cpu_time))
+ {
+ return 1;
+ }
+
+ //Getting Tolerance Value
+ if(getFixedSizeDoubleMatrixInList(5,6,temp1,temp2,&tol_val))
+ {
+ return 1;
+ }
+
+
+ //Initialization of parameters
+ nVars=x1_rows;
+ nCons=0;
+
+ // Starting Ipopt
+
+ SmartPtr<minbndNLP> Prob = new minbndNLP(nVars,nCons,varLB,varUB);
+
+ SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
+ app->RethrowNonIpoptException(true);
+
+ ////////// Managing the parameters //////////
+
+ app->Options()->SetNumericValue("tol", *tol_val);
+ app->Options()->SetIntegerValue("max_iter", (int)*max_iter);
+ app->Options()->SetNumericValue("max_cpu_time", *cpu_time);
+
+ ///////// Initialize the IpoptApplication and process the options /////////
+ ApplicationReturnStatus status;
+ status = app->Initialize();
+ if (status != Solve_Succeeded) {
+ sciprint("\n*** Error during initialization!\n");
+ return (int) status;
+ }
+ // Ask Ipopt to solve the problem
+ status = app->OptimizeTNLP(Prob);
+
+ //Get the solve statistics
+ cpuTime = app->Statistics()->TotalCPUTime();
+ app->Statistics()->NumberOfEvaluations(int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval);
+ app->Statistics()->Infeasibilities(dual_inf, constr_viol, complementarity, kkt_error);
+ rstatus = Prob->returnStatus();
+
+ ////////// Manage the output argument //////////
+
+
+ fX = Prob->getX();
+ ObjVal = Prob->getObjVal();
+ iteration = Prob->iterCount();
+ fobj_eval=(double)int_fobj_eval;
+ fZl = Prob->getZl();
+ fZu = Prob->getZu();
+
+ if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(2, 1, 1, &ObjVal))
+ {
+ return 1;
+ }
+
+ if (returnIntegerMatrixToScilab(3, 1, 1, &rstatus))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(4, 1, 1, &iteration))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(5, 1, 1, &cpuTime))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(6, 1, 1, &fobj_eval))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(7, 1, 1, &dual_inf))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(8, 1, nVars, fZl))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(9, 1, nVars, fZu))
+ {
+ return 1;
+ }
+
+
+ return 0;
+}
+}
diff --git a/sci_gateway/cpp/sci_ipoptfmincon.cpp b/sci_gateway/cpp/sci_ipoptfmincon.cpp
new file mode 100644
index 0000000..551af41
--- /dev/null
+++ b/sci_gateway/cpp/sci_ipoptfmincon.cpp
@@ -0,0 +1,273 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "sci_iofunc.hpp"
+#include "IpIpoptApplication.hpp"
+#include "minconNLP.hpp"
+#include <IpSolveStatistics.hpp>
+
+extern "C"
+{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <iostream>
+
+using namespace std;
+
+int sci_solveminconp(char *fname)
+{
+ using namespace Ipopt;
+
+ CheckInputArgument(pvApiCtx, 20, 20);
+ CheckOutputArgument(pvApiCtx, 12, 12);
+
+ // Error management variable
+ SciErr sciErr;
+
+ //Function pointers, input matrix(Starting point) pointer, flag variable
+ int* funptr=NULL;
+ int* gradhesptr=NULL;
+ double *x0ptr=NULL, *lbptr=NULL, *ubptr=NULL,*Aptr=NULL, *bptr=NULL, *Aeqptr=NULL, *beqptr=NULL;
+ double flag1=0,flag2=0,flag3=0,nonlinCon=0,nonlinIneqCon=0;
+
+
+ // Input arguments
+ double *cpu_time=NULL,*max_iter=NULL;
+ static unsigned int nVars = 0,nCons = 0;
+ unsigned int temp1 = 0,temp2 = 0, iret = 0;
+ int x0_rows=0, x0_cols=0, lb_rows=0, lb_cols=0, ub_rows=0, ub_cols=0, A_rows=0, A_cols=0, b_rows=0, b_cols=0, Aeq_rows=0, Aeq_cols=0, beq_rows=0, beq_cols=0;
+
+ // Output arguments
+ double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ double dual_inf, constr_viol, complementarity, kkt_error;
+ double *fGrad = NULL;
+ double *fHess = NULL;
+ double *fLambda = NULL;
+ double *fZl=NULL;
+ double *fZu=NULL;
+ int rstatus = 0;
+ int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
+
+ ////////// Manage the input argument //////////
+
+ //Objective Function
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+
+ //Function for gradient and hessian
+ if(getFunctionFromScilab(2,&gradhesptr))
+ {
+ return 1;
+ }
+
+ //x0(starting point) matrix from scilab
+ if(getDoubleMatrixFromScilab(18, &x0_rows, &x0_cols, &x0ptr))
+ {
+ return 1;
+ }
+
+ //Getting number of iterations
+ if(getFixedSizeDoubleMatrixInList(19,2,temp1,temp2,&max_iter))
+ {
+ return 1;
+ }
+
+ //Getting Cpu Time
+ if(getFixedSizeDoubleMatrixInList(19,4,temp1,temp2,&cpu_time))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing linear inequality constraints
+ if(getDoubleMatrixFromScilab(3, &A_rows, &A_cols, &Aptr))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing bounds of linear inequality constraints
+ if(getDoubleMatrixFromScilab(4, &b_rows, &b_cols, &bptr))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing linear equality constraints
+ if(getDoubleMatrixFromScilab(5, &Aeq_rows, &Aeq_cols, &Aeqptr))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing bounds of linear inequality constraints
+ if(getDoubleMatrixFromScilab(6, &beq_rows, &beq_cols, &beqptr))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing linear inequality constraints
+ if(getDoubleMatrixFromScilab(7, &lb_rows, &lb_cols, &lbptr))
+ {
+ return 1;
+ }
+
+ //Getting matrix representing linear inequality constraints
+ if(getDoubleMatrixFromScilab(8, &ub_rows, &ub_cols, &ubptr))
+ {
+ return 1;
+ }
+
+ //Number of non-linear constraints
+ if(getDoubleFromScilab(9, &nonlinCon))
+ {
+ return 1;
+ }
+
+ //Number of non-linear inequality constraints
+ if(getDoubleFromScilab(10, &nonlinIneqCon))
+ {
+ return 1;
+ }
+
+ //Getting the required flag variables
+
+ if(getDoubleFromScilab(12, &flag1))
+ {
+ return 1;
+ }
+
+ if(getDoubleFromScilab(14, &flag2))
+ {
+ return 1;
+ }
+
+ if(getDoubleFromScilab(16, &flag3))
+ {
+ return 1;
+ }
+
+ //Number of variables and constraints
+ nVars = x0_cols;
+ nCons = A_rows + Aeq_rows + nonlinCon;
+
+
+ // Starting Ipopt
+
+ SmartPtr<minconNLP> Prob = new minconNLP(nVars, nCons, x0ptr, Aptr, bptr, Aeqptr, beqptr, A_rows, A_cols, b_rows, b_cols, Aeq_rows, Aeq_cols, beq_rows, beq_cols, lbptr, ubptr, nonlinCon, nonlinIneqCon, flag1, flag2, flag3);
+ SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
+ app->RethrowNonIpoptException(true);
+
+ ////////// Managing the parameters //////////
+
+ app->Options()->SetNumericValue("tol", 1e-7);
+ app->Options()->SetIntegerValue("max_iter", (int)*max_iter);
+ app->Options()->SetNumericValue("max_cpu_time", *cpu_time);
+
+ ///////// Initialize the IpoptApplication and process the options /////////
+ ApplicationReturnStatus status;
+ status = app->Initialize();
+ if (status != Solve_Succeeded)
+ {
+ sciprint("\n*** Error during initialization!\n");
+ return (int) status;
+ }
+
+ // Ask Ipopt to solve the problem
+ status = app->OptimizeTNLP(Prob);
+
+ //Get the solve statistics
+ cpuTime = app->Statistics()->TotalCPUTime();
+ app->Statistics()->NumberOfEvaluations(int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval);
+ app->Statistics()->Infeasibilities(dual_inf, constr_viol, complementarity, kkt_error);
+ rstatus = Prob->returnStatus();
+ fobj_eval=(double)int_fobj_eval;
+
+ ////////// Manage the output argument //////////
+
+ fX = Prob->getX();
+ fGrad = Prob->getGrad();
+ fHess = Prob->getHess();
+ fLambda = Prob->getLambda();
+ fZl = Prob->getZl();
+ fZu = Prob->getZu();
+ ObjVal = Prob->getObjVal();
+ iteration = Prob->iterCount();
+
+ if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(2, 1, 1, &ObjVal))
+ {
+ return 1;
+ }
+
+ if (returnIntegerMatrixToScilab(3, 1, 1, &rstatus))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(4, 1, 1, &iteration))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(5, 1, 1, &cpuTime))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(6, 1, 1, &fobj_eval))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(7, 1, 1, &dual_inf))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(8, 1, nCons, fLambda))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(9, 1, nVars, fZl))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(10, 1, nVars, fZu))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(11, 1, nVars, fGrad))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(12, 1, nVars*nVars, fHess))
+ {
+ return 1;
+ }
+
+ // As the SmartPtrs go out of scope, the reference count
+ // will be decremented and the objects will automatically
+ // be deleted.*/
+
+ return 0;
+}
+}
diff --git a/sci_gateway/cpp/sci_ipoptfminunc.cpp b/sci_gateway/cpp/sci_ipoptfminunc.cpp
new file mode 100644
index 0000000..19c59ac
--- /dev/null
+++ b/sci_gateway/cpp/sci_ipoptfminunc.cpp
@@ -0,0 +1,201 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "sci_iofunc.hpp"
+#include "IpIpoptApplication.hpp"
+#include "minuncNLP.hpp"
+#include <IpSolveStatistics.hpp>
+
+extern "C"
+{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <iostream>
+
+using namespace std;
+
+int sci_solveminuncp(char *fname)
+{
+ using namespace Ipopt;
+
+ CheckInputArgument(pvApiCtx, 8, 8);
+ CheckOutputArgument(pvApiCtx, 9, 9);
+
+ // Error management variable
+ SciErr sciErr;
+
+ //Function pointers, input matrix(Starting point) pointer, flag variable
+ int* funptr=NULL;
+ int* gradhesptr=NULL;
+ double* x0ptr=NULL;
+ double flag1,flag2;
+
+
+ // Input arguments
+ double *cpu_time=NULL,*max_iter=NULL;
+ static unsigned int nVars = 0,nCons = 0;
+ unsigned int temp1 = 0,temp2 = 0, iret = 0;
+ int x0_rows, x0_cols;
+
+ // Output arguments
+ double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ double dual_inf, constr_viol, complementarity, kkt_error;
+ double *fGrad= NULL;
+ double *fHess= NULL;
+ int rstatus = 0;
+ int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
+
+ ////////// Manage the input argument //////////
+
+ //Objective Function
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+
+ //Function for gradient and hessian
+ if(getFunctionFromScilab(2,&gradhesptr))
+ {
+ return 1;
+ }
+
+ //Flag for Gradient from Scilab
+ if(getDoubleFromScilab(3, &flag1))
+ {
+ return 1;
+ }
+
+ //Flag for Hessian from Scilab
+ if(getDoubleFromScilab(5, &flag2))
+ {
+ return 1;
+ }
+
+ //x0(starting point) matrix from scilab
+ if(getDoubleMatrixFromScilab(7, &x0_rows, &x0_cols, &x0ptr))
+ {
+ return 1;
+ }
+
+ //Getting number of iterations
+ if(getFixedSizeDoubleMatrixInList(8,2,temp1,temp2,&max_iter))
+ {
+ return 1;
+ }
+
+ //Getting Cpu Time
+ if(getFixedSizeDoubleMatrixInList(8,4,temp1,temp2,&cpu_time))
+ {
+ return 1;
+ }
+
+
+ //Initialization of parameters
+ nVars=x0_cols;
+ nCons=0;
+
+ // Starting Ipopt
+
+ SmartPtr<minuncNLP> Prob = new minuncNLP(nVars, nCons, x0ptr, flag1, flag2);
+ SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
+ app->RethrowNonIpoptException(true);
+
+ ////////// Managing the parameters //////////
+
+ app->Options()->SetNumericValue("tol", 1e-7);
+ app->Options()->SetIntegerValue("max_iter", (int)*max_iter);
+ app->Options()->SetNumericValue("max_cpu_time", *cpu_time);
+
+ ///////// Initialize the IpoptApplication and process the options /////////
+ ApplicationReturnStatus status;
+ status = app->Initialize();
+ if (status != Solve_Succeeded)
+ {
+ sciprint("\n*** Error during initialization!\n");
+ return (int) status;
+ }
+ // Ask Ipopt to solve the problem
+
+ status = app->OptimizeTNLP(Prob);
+
+ cpuTime = app->Statistics()->TotalCPUTime();
+
+ app->Statistics()->NumberOfEvaluations(int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval);
+
+ app->Statistics()->Infeasibilities(dual_inf, constr_viol, complementarity, kkt_error);
+
+ rstatus = Prob->returnStatus();
+
+ ////////// Manage the output argument //////////
+
+ fX = Prob->getX();
+ fGrad = Prob->getGrad();
+ fHess = Prob->getHess();
+ ObjVal = Prob->getObjVal();
+ iteration = Prob->iterCount();
+ fobj_eval = (double)int_fobj_eval;
+
+ if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(2, 1, 1, &ObjVal))
+ {
+ return 1;
+ }
+
+ if (returnIntegerMatrixToScilab(3, 1, 1, &rstatus))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(4, 1, 1, &iteration))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(5, 1, 1, &cpuTime))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(6, 1, 1, &fobj_eval))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(7, 1, 1, &dual_inf))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(8, 1, nVars, fGrad))
+ {
+ return 1;
+ }
+
+ if (returnDoubleMatrixToScilab(9, 1, nVars*nVars, fHess))
+ {
+ return 1;
+ }
+
+ // As the SmartPtrs go out of scope, the reference count
+ // will be decremented and the objects will automatically
+ // be deleted.*/
+
+ return 0;
+}
+}
diff --git a/sci_gateway/cpp/sci_minbndNLP.cpp b/sci_gateway/cpp/sci_minbndNLP.cpp
new file mode 100644
index 0000000..9a7024e
--- /dev/null
+++ b/sci_gateway/cpp/sci_minbndNLP.cpp
@@ -0,0 +1,353 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "minbndNLP.hpp"
+#include "IpIpoptData.hpp"
+#include "sci_iofunc.hpp"
+
+extern "C"
+{
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <string.h>
+#include <assert.h>
+#include <iostream>
+
+using namespace std;
+using namespace Ipopt;
+
+minbndNLP::~minbndNLP()
+{
+ free(finalX_);
+ free(finalZu_);
+ free(finalZl_);
+}
+
+//get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory
+bool minbndNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style)
+{
+ n=numVars_; // Number of variables
+ m=numConstr_; // Number of constraints
+ nnz_jac_g = 0; // No. of elements in Jacobian of constraints
+ nnz_h_lag = n*(n+1)/2; // No. of elements in lower traingle of Hessian of the Lagrangian.
+ index_style=C_STYLE; // Index style of matrices
+
+ return true;
+}
+
+//get variable and constraint bound info
+bool minbndNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u)
+{
+ for(Index i=0;i<n;i++)
+ {
+ x_l[i]=varLB_[i]+0.0000001;
+ x_u[i]=varUB_[i]-0.0000001;
+ }
+
+ g_l=NULL;
+ g_u=NULL;
+
+ return true;
+}
+
+// return the value of the constraints: g(x)
+bool minbndNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
+{
+ g=NULL;
+ return true;
+}
+
+// return the structure or values of the jacobian
+bool minbndNLP::eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values)
+{
+ if (values == NULL)
+ {
+ // return the structure of the jacobian of the constraints
+ iRow=NULL;
+ jCol=NULL;
+ }
+ else
+ {
+ values=NULL;
+ }
+
+ return true;
+}
+
+//get value of objective function at vector x
+bool minbndNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
+{
+ int* funptr=NULL;
+ double check;
+ Index i;
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+ char name[20]="f";
+ double obj=0;
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 3, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 3;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *funptr;
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ if(getDoubleFromScilab(4,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+
+ return true;
+ }
+ else
+ {
+ if(getDoubleFromScilab(3,&obj))
+ {
+ sciprint("No obj value");
+ return 1;
+ }
+ obj_value=obj;
+ return true;
+ }
+}
+
+//get value of gradient of objective function at vector x.
+bool minbndNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
+{
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ Index i;
+ double t=1;
+ createMatrixOfDouble(pvApiCtx, 3, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 4,t);
+ int positionFirstElementOnStackForScilabFunction = 3;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+
+ double* resg;
+ double check;
+ int x0_rows,x0_cols;
+
+ if(getDoubleFromScilab(4,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ /*sciprint("Gradient is not defined at the point [");
+ for(i=0;i<numVars_;i++)
+ {
+ if(i==numVars_-1)
+ sciprint("%d",x[i]);
+ else
+ sciprint("%d,",x[i]);
+ }
+ sciprint("], So the Point is skipped by IPopt during Iterations");*/
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(3, &x0_rows, &x0_cols, &resg))
+ {
+ return true;
+ }
+
+ for(i=0;i<numVars_;i++)
+ {
+ grad_f[i]=resg[i];
+ }
+ return true;
+ }
+}
+
+// This method sets initial values for required vectors . For now we are assuming 0 to all values.
+bool minbndNLP::get_starting_point(Index n, bool init_x, Number* x,bool init_z, Number* z_L, Number* z_U,Index m, bool init_lambda,Number* lambda)
+{
+ Index i;
+ for(i=0;i<n;i++)
+ x[i]=NULL;
+
+ return true;
+}
+
+/*
+ * Return either the sparsity structure of the Hessian of the Lagrangian,
+ * or the values of the Hessian of the Lagrangian for the given values for
+ * x,lambda,obj_factor.
+*/
+
+bool minbndNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values)
+{
+
+
+ if (values==NULL)
+ {
+ Index idx=0;
+ for (Index row = 0; row < numVars_; row++)
+ {
+ for (Index col = 0; col <= row; col++)
+ {
+ iRow[idx] = row;
+ jCol[idx] = col;
+ idx++;
+ }
+ }
+ }
+ else
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+
+ double *xNew=x;
+ Index i;
+ double t=2;
+
+ createMatrixOfDouble(pvApiCtx, 3, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 4,t);
+ int positionFirstElementOnStackForScilabFunction = 3;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resh;
+ double check;
+ int x0_rows,x0_cols;
+
+ if(getDoubleFromScilab(4,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ /*sciprint("Hessian is not defined at the point [");
+ for(i=0;i<numVars_;i++)
+ {
+ if(i=numVars_-1)
+ sciprint("%d",x[i]);
+ else
+ sciprint("%d,",x[i]);
+ }
+ sciprint("], So the Point is skipped by IPopt during Iterations");*/
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(3, &x0_rows, &x0_cols, &resh))
+ {
+ sciprint("No results");
+ return 1;
+ }
+ Index index=0;
+ for (Index row=0;row < numVars_ ;++row)
+ {
+ for (Index col=0; col <= row; ++col)
+ {
+ values[index++]=obj_factor*(resh[numVars_*row+col]);
+ }
+ }
+ }
+
+ }
+
+ return true;
+}
+
+
+void minbndNLP::finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda, Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq)
+{
+ finalX_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<numVars_; i++)
+ {
+ finalX_[i] = x[i];
+ }
+
+ finalZl_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<n; i++)
+ {
+ finalZl_[i] = z_L[i];
+ }
+
+ finalZu_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<n; i++)
+ {
+ finalZu_[i] = z_U[i];
+ }
+
+ finalObjVal_ = obj_value;
+ status_ = status;
+ if (status_ == 0 | status_ == 1 | status_ == 2)
+ {
+ iter_ = ip_data->iter_count();
+ }
+}
+
+
+const double * minbndNLP::getX()
+{
+ return finalX_;
+}
+
+double minbndNLP::getObjVal()
+{
+ return finalObjVal_;
+}
+
+const double * minbndNLP::getZl()
+{
+ return finalZl_;
+}
+
+const double * minbndNLP::getZu()
+{
+ return finalZu_;
+}
+
+double minbndNLP::iterCount()
+{
+ return (double)iter_;
+}
+
+int minbndNLP::returnStatus()
+{
+ return status_;
+}
+
+}
+
diff --git a/sci_gateway/cpp/sci_minconNLP.cpp b/sci_gateway/cpp/sci_minconNLP.cpp
new file mode 100644
index 0000000..2c6d6af
--- /dev/null
+++ b/sci_gateway/cpp/sci_minconNLP.cpp
@@ -0,0 +1,797 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "minconNLP.hpp"
+#include "IpIpoptData.hpp"
+#include "sci_iofunc.hpp"
+
+extern "C"
+{
+
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <string.h>
+#include <assert.h>
+#include <iostream>
+
+using namespace std;
+using namespace Ipopt;
+
+minconNLP::~minconNLP()
+{
+ free(finalX_);
+ free(finalGradient_);
+ free(finalHessian_);
+ free(finalZu_);
+ free(finalZl_);
+ free(finalLambda_);
+}
+
+//get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory
+bool minconNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style)
+{
+ finalGradient_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ finalHessian_ = (double*)malloc(sizeof(double) * numVars_ * numVars_);
+
+ n=numVars_; // Number of variables
+ m=numConstr_; // Number of constraints
+
+ nnz_jac_g = n*m; // No. of elements in Jacobian of constraints
+ nnz_h_lag = n*(n+1)/2; // No. of elements in lower traingle of Hessian of the Lagrangian.
+
+ index_style=C_STYLE; // Index style of matrices
+ return true;
+}
+
+//get variable and constraint bound info
+bool minconNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u)
+{
+ unsigned int i;
+
+ //assigning bounds for the variables
+ for(i=0;i<n;i++)
+ {
+ x_l[i]=varLB_[i];
+ x_u[i]=varUB_[i];
+ }
+
+ if(m==0)
+ {
+ g_l=NULL;
+ g_u=NULL;
+ }
+
+ else
+ {
+ unsigned int c=0;
+
+ //bounds of non-linear inequality constraints
+ for(i=0;i<nonlinIneqCon_;i++)
+ {
+ g_l[c]=-1.0e19;
+ g_u[c]=0;
+ c++;
+ }
+
+ //bounds of non-linear equality constraints
+ for(i=0;i<nonlinCon_-nonlinIneqCon_;i++)
+ {
+ g_l[c]=g_u[c]=0;
+ c++;
+ }
+
+ //bounds of linear equality constraints
+ for(i=0;i<Aeqrows_;i++)
+ {
+ g_l[c]=g_u[c]=beq_[i];
+ c++;
+ }
+
+ //bounds of linear inequality constraints
+ for(i=0;i<Arows_;i++)
+ {
+ g_l[c]=-1.0e19;
+ g_u[c]=b_[i];
+
+ c++;
+ }
+
+ }
+
+ return true;
+}
+
+// return the value of the constraints: g(x)
+bool minconNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
+{
+ // return the value of the constraints: g(x)
+
+ unsigned int i;
+ unsigned int j;
+
+ if(m==0)
+ g=NULL;
+
+ else
+ {
+ unsigned int c=0;
+
+ //value of non-linear constraints
+ if(nonlinCon_!=0)
+ {
+ int* constr=NULL;
+ if(getFunctionFromScilab(11,&constr))
+ {
+ return 1;
+ }
+ char name[20]="addnlc1";
+ double *xNew=x;
+ double check;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *constr;
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resc;
+ int xC_rows,xC_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &xC_rows, &xC_cols, &resc))
+ {
+ sciprint("No results");
+ return 1;
+
+ }
+
+ for(i=0;i<nonlinCon_;i++)
+ {
+ g[c]=resc[i];
+ c++;
+ }
+ }
+ }
+
+ //value of linear equality constraints
+ for(i=0;i<Aeqrows_;i++)
+ {
+ g[c]=0;
+ for(j=0;j<Aeqcols_;j++)
+ g[c] += Aeq_[j*Aeqrows_+i]*x[j];
+ c++;
+ }
+
+ //value of linear inequality constraints
+ for(i=0;i<Arows_;i++)
+ {
+ g[c]=0;
+ for(j=0;j<Acols_;j++)
+ g[c] += A_[j*Arows_+i]*x[j];
+ c++;
+ }
+
+ }
+
+ return true;
+}
+
+// return the structure or values of the jacobian
+bool minconNLP::eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values)
+{
+ if (values == NULL)
+ {
+ if(m==0)// return the structure of the jacobian of the constraints
+ {
+ iRow=NULL;
+ jCol=NULL;
+ }
+
+ else
+ {
+ unsigned int i,j,idx=0;
+ for(int i=0;i<m;i++)
+ for(j=0;j<n;j++)
+ {
+ iRow[idx]=i;
+ jCol[idx]=j;
+ idx++;
+ }
+ }
+ }
+
+ else
+ {
+ if(m==0)
+ values=NULL;
+
+ else
+ {
+ unsigned int i,j,c=0;
+ double check;
+ //jacobian of non-linear constraints
+ if(nonlinCon_!=0)
+ {
+ if(flag3_==0)
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double t=3;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 19,t);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resj;
+ int xJ_rows,xJ_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &xJ_rows, &xJ_cols, &resj))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ for(i=0;i<nonlinCon_;i++)
+ {
+ for(j=0;j<n;j++)
+ {
+ values[c] = resj[j*(int)nonlinCon_+i];
+ c++;
+ }
+ }
+ }
+ }
+
+ else
+ {
+ int* jacptr=NULL;
+ if(getFunctionFromScilab(17,&jacptr))
+ {
+ return 1;
+ }
+
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *jacptr;
+ char name[20]="addcGrad1";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resj;
+ int xJ_rows,xJ_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &xJ_rows, &xJ_cols, &resj))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ for(i=0;i<nonlinCon_;i++)
+ for(j=0;j<n;j++)
+ {
+ values[c] = resj[j*(int)nonlinCon_+i];
+ c++;
+ }
+ }
+ }
+ }
+
+ //jacobian of linear equality constraints
+ for(i=0;i<Aeqrows_;i++)
+ {
+ for(j=0;j<Aeqcols_;j++)
+ {
+ values[c] = Aeq_[j*Aeqrows_+i];
+ c++;
+ }
+ }
+
+ //jacobian of linear inequality constraints
+ for(i=0;i<Arows_;i++)
+ {
+ for(j=0;j<Acols_;j++)
+ {
+ values[c] = A_[j*Arows_+i];
+ c++;
+ }
+ }
+
+ }
+ }
+
+ return true;
+}
+
+//get value of objective function at vector x
+bool minconNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
+{
+ int* funptr=NULL;
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+ char name[20]="f";
+ double obj=0;
+ double *xNew=x;
+ double check;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *funptr;
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleFromScilab(18,&obj))
+ {
+ sciprint("No obj value");
+ return 1;
+ }
+ obj_value=obj;
+
+ return true;
+ }
+}
+
+//get value of gradient of objective function at vector x.
+bool minconNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
+{
+ if (flag1_==0)
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double t=1;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 19,t);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ else
+ {
+ int* gradptr=NULL;
+ if(getFunctionFromScilab(13,&gradptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradptr;
+ char name[20]="fGrad1";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ double* resg;
+ double check;
+ int x0_rows,x0_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &x0_rows, &x0_cols, &resg))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+
+ Index i;
+ for(i=0;i<numVars_;i++)
+ {
+ grad_f[i]=resg[i];
+ finalGradient_[i]=resg[i];
+ }
+ }
+ return true;
+}
+
+// This method sets initial values for required vectors . For now we are assuming 0 to all values.
+bool minconNLP::get_starting_point(Index n, bool init_x, Number* x,bool init_z, Number* z_L, Number* z_U,Index m, bool init_lambda,Number* lambda)
+{
+ assert(init_x == true);
+ assert(init_z == false);
+ assert(init_lambda == false);
+ if (init_x == true)
+ { //we need to set initial values for vector x
+ for (Index var=0;var<n;var++)
+ x[var]=varGuess_[var];
+ }
+
+ return true;
+}
+
+/*
+ * Return either the sparsity structure of the Hessian of the Lagrangian,
+ * or the values of the Hessian of the Lagrangian for the given values for
+ * x,lambda,obj_factor.
+*/
+
+bool minconNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values)
+{
+ if (values==NULL)
+ {
+ Index idx=0;
+ for (Index row = 0; row < numVars_; row++)
+ {
+ for (Index col = 0; col <= row; col++)
+ {
+ iRow[idx] = row;
+ jCol[idx] = col;
+ idx++;
+ }
+ }
+ }
+
+ else
+ {
+ double check;
+ //hessian of the objective function
+ if(flag2_==0)
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double t=2;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 19,t);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resTemph;
+ int x0_rows,x0_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &x0_rows, &x0_cols, &resTemph))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ double* resh=(double*)malloc(sizeof(double)*n*n);
+ Index i;
+ for(i=0;i<numVars_*numVars_;i++)
+ {
+ resh[i]=resTemph[i];
+ }
+
+ //sum of hessians of constraints each multiplied by its own lambda factor
+ double* sum=(double*)malloc(sizeof(double)*n*n);
+ if(nonlinCon_!=0)
+ {
+
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+
+ double *xNew=x;
+ double t=4;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 19,t);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resCh;
+ int xCh_rows,xCh_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &xCh_rows, &xCh_cols, &resCh))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ Index j;
+
+ for(i=0;i<numVars_*numVars_;i++)
+ {
+ sum[i]=0;
+ for(j=0;j<nonlinCon_;j++)
+ sum[i]+=lambda[j]*resCh[i*(int)nonlinCon_+j];
+ }
+ }
+ }
+
+ else
+ {
+ for(i=0;i<numVars_*numVars_;i++)
+ sum[i]=0;
+ }
+
+ //computing the lagrangian
+ Index index=0;
+ for (Index row=0;row < numVars_ ;++row)
+ {
+ for (Index col=0; col <= row; ++col)
+ {
+ values[index++]=obj_factor*(resh[numVars_*row+col])+sum[numVars_*row+col];
+ }
+ }
+
+ free(resh);
+ free(sum);
+ }
+ }
+ else
+ {
+ int* hessptr=NULL;
+ if(getFunctionFromScilab(15,&hessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double *lambdaNew=lambda;
+ double objfac=obj_factor;
+ createMatrixOfDouble(pvApiCtx, 18, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 19,objfac);
+ createMatrixOfDouble(pvApiCtx, 20, 1, numConstr_, lambdaNew);
+ int positionFirstElementOnStackForScilabFunction = 18;
+ int numberOfRhsOnScilabFunction = 3;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *hessptr;
+ char name[20]="lHess1";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ double* resCh;
+ int xCh_rows,xCh_cols;
+ if(getDoubleFromScilab(19,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleMatrixFromScilab(18, &xCh_rows, &xCh_cols, &resCh))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ Index index=0;
+ for (Index row=0;row < numVars_ ;++row)
+ {
+ for (Index col=0; col <= row; ++col)
+ {
+ values[index++]=resCh[numVars_*row+col];
+ }
+ }
+ }
+ }
+
+
+ Index index=0;
+ for (Index row=0;row < numVars_ ;++row)
+ {
+ for (Index col=0; col <= row; ++col)
+ {
+ finalHessian_[n*row+col]=values[index++];
+ }
+ }
+
+ index=0;
+ for (Index col=0;col < numVars_ ;++col)
+ {
+ for (Index row=0; row <= col; ++row)
+ {
+ finalHessian_[n*row+col]=values[index++];
+ }
+ }
+ }
+
+ return true;
+}
+
+//returning the results
+void minconNLP::finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda, Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq)
+{
+ finalX_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<numVars_; i++)
+ {
+ finalX_[i] = x[i];
+ }
+
+ finalZl_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<n; i++)
+ {
+ finalZl_[i] = z_L[i];
+ }
+
+ finalZu_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<n; i++)
+ {
+ finalZu_[i] = z_U[i];
+ }
+
+ finalLambda_ = (double*)malloc(sizeof(double) * numConstr_ * 1);
+ for (Index i=0; i<m; i++)
+ {
+ finalLambda_[i] = lambda[i];
+ }
+
+ finalObjVal_ = obj_value;
+ status_ = status;
+ iter_ = ip_data->iter_count();
+}
+
+
+const double * minconNLP::getX()
+{
+ return finalX_;
+}
+
+const double * minconNLP::getGrad()
+{
+ return finalGradient_;
+}
+
+const double * minconNLP::getHess()
+{
+ return finalHessian_;
+}
+
+const double * minconNLP::getZl()
+{
+ return finalZl_;
+}
+
+const double * minconNLP::getZu()
+{
+ return finalZu_;
+}
+
+const double * minconNLP::getLambda()
+{
+ return finalLambda_;
+}
+
+double minconNLP::getObjVal()
+{
+ return finalObjVal_;
+}
+
+double minconNLP::iterCount()
+{
+ return (double)iter_;
+}
+
+int minconNLP::returnStatus()
+{
+ return status_;
+}
+
+}
+
+
+
diff --git a/sci_gateway/cpp/sci_minuncNLP.cpp b/sci_gateway/cpp/sci_minuncNLP.cpp
new file mode 100644
index 0000000..874c093
--- /dev/null
+++ b/sci_gateway/cpp/sci_minuncNLP.cpp
@@ -0,0 +1,377 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: rvidhyadar@gmail.com & vignesh2496@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
+
+
+#include "minuncNLP.hpp"
+#include "IpIpoptData.hpp"
+#include "sci_iofunc.hpp"
+
+extern "C"
+{
+
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <localization.h>
+#include <sciprint.h>
+#include <string.h>
+#include <assert.h>
+#include <iostream>
+
+using namespace std;
+using namespace Ipopt;
+
+minuncNLP::~minuncNLP()
+{
+ free(finalX_);
+ free(finalGradient_);
+ free(finalHessian_);
+}
+
+//get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory
+bool minuncNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style)
+{
+ finalGradient_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ finalHessian_ = (double*)malloc(sizeof(double) * numVars_ * numVars_);
+ n=numVars_; // Number of variables
+ m=numConstr_; // Number of constraints
+ nnz_jac_g = 0; // No. of elements in Jacobian of constraints
+ nnz_h_lag = n*(n+1)/2; // No. of elements in lower traingle of Hessian of the Lagrangian.
+ index_style=C_STYLE; // Index style of matrices
+ return true;
+}
+
+//get variable and constraint bound info
+bool minuncNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u)
+{
+ unsigned int i;
+ for(i=0;i<n;i++)
+ {
+ x_l[i]=-1.0e19;
+ x_u[i]=1.0e19;
+ }
+
+ g_l=NULL;
+ g_u=NULL;
+ return true;
+}
+
+// return the value of the constraints: g(x)
+bool minuncNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
+{
+ // return the value of the constraints: g(x)
+ g=NULL;
+ return true;
+}
+
+// return the structure or values of the jacobian
+bool minuncNLP::eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index nele_jac, Index* iRow, Index *jCol,Number* values)
+{
+ if (values == NULL)
+ {
+ // return the structure of the jacobian of the constraints
+ iRow=NULL;
+ jCol=NULL;
+ }
+ else
+ {
+ values=NULL;
+ }
+
+ return true;
+}
+
+//get value of objective function at vector x
+bool minuncNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
+{
+ double check;
+ int* funptr=NULL;
+ if(getFunctionFromScilab(1,&funptr))
+ {
+ return 1;
+ }
+ char name[20]="f";
+ double obj=0;
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 7;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *funptr;
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+
+ if(getDoubleFromScilab(8,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ if(getDoubleFromScilab(7,&obj))
+ {
+ sciprint("No obj value");
+ return 1;
+ }
+ obj_value=obj;
+ }
+ return true;
+}
+
+//get value of gradient of objective function at vector x.
+bool minuncNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
+{
+ double check;
+ if (flag1_==0)
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double t=1;
+ createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 8,t);
+ int positionFirstElementOnStackForScilabFunction = 7;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ else if (flag1_==1)
+ {
+ int* gradptr=NULL;
+ if(getFunctionFromScilab(4,&gradptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 7;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradptr;
+ char name[20]="fGrad1";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ if(getDoubleFromScilab(8,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ double* resg;
+ int x0_rows,x0_cols;
+ if(getDoubleMatrixFromScilab(7, &x0_rows, &x0_cols, &resg))
+ {
+ sciprint("No results");
+ return 1;
+
+ }
+
+ Index i;
+ for(i=0;i<numVars_;i++)
+ {
+ grad_f[i]=resg[i];
+ finalGradient_[i]=resg[i];
+ }
+ }
+ return true;
+}
+
+// This method sets initial values for required vectors . For now we are assuming 0 to all values.
+bool minuncNLP::get_starting_point(Index n, bool init_x, Number* x,bool init_z, Number* z_L, Number* z_U,Index m, bool init_lambda,Number* lambda)
+{
+ assert(init_x == true);
+ assert(init_z == false);
+ assert(init_lambda == false);
+ if (init_x == true)
+ { //we need to set initial values for vector x
+ for (Index var=0;var<n;var++)
+ x[var]=varGuess_[var];//initialize with 0 or we can change.
+ }
+
+ return true;
+}
+
+/*
+ * Return either the sparsity structure of the Hessian of the Lagrangian,
+ * or the values of the Hessian of the Lagrangian for the given values for
+ * x,lambda,obj_factor.
+*/
+
+bool minuncNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, Index m, const Number* lambda,bool new_lambda, Index nele_hess, Index* iRow,Index* jCol, Number* values)
+{
+ double check;
+ if (values==NULL)
+ {
+ Index idx=0;
+ for (Index row = 0; row < numVars_; row++)
+ {
+ for (Index col = 0; col <= row; col++)
+ {
+ iRow[idx] = row;
+ jCol[idx] = col;
+ idx++;
+ }
+ }
+ }
+
+ else
+ {
+ if(flag2_==0)
+ {
+ int* gradhessptr=NULL;
+ if(getFunctionFromScilab(2,&gradhessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ double t=2;
+ createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
+ createScalarDouble(pvApiCtx, 8,t);
+ int positionFirstElementOnStackForScilabFunction = 7;
+ int numberOfRhsOnScilabFunction = 2;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *gradhessptr;
+ char name[20]="gradhess";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ else if (flag2_==1)
+ {
+ int* hessptr=NULL;
+ if(getFunctionFromScilab(6,&hessptr))
+ {
+ return 1;
+ }
+ double *xNew=x;
+ createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
+ int positionFirstElementOnStackForScilabFunction = 7;
+ int numberOfRhsOnScilabFunction = 1;
+ int numberOfLhsOnScilabFunction = 2;
+ int pointerOnScilabFunction = *hessptr;
+ char name[20]="fHess1";
+
+ C2F(scistring)(&positionFirstElementOnStackForScilabFunction,name,
+ &numberOfLhsOnScilabFunction,
+ &numberOfRhsOnScilabFunction,(unsigned long)strlen(name));
+ }
+
+ if(getDoubleFromScilab(8,&check))
+ {
+ return true;
+ }
+ if (check==1)
+ {
+ return true;
+ }
+ else
+ {
+ double* resh;
+ int x0_rows,x0_cols;
+ if(getDoubleMatrixFromScilab(7, &x0_rows, &x0_cols, &resh))
+ {
+ sciprint("No results");
+ return 1;
+ }
+
+ Index index=0;
+ for (Index row=0;row < numVars_ ;++row)
+ {
+ for (Index col=0; col <= row; ++col)
+ {
+ values[index++]=obj_factor*(resh[numVars_*row+col]);
+ }
+ }
+
+ Index i;
+ for(i=0;i<numVars_*numVars_;i++)
+ {
+ finalHessian_[i]=resh[i];
+ }
+ }
+ }
+
+ return true;
+}
+
+
+void minuncNLP::finalize_solution(SolverReturn status,Index n, const Number* x, const Number* z_L, const Number* z_U,Index m, const Number* g, const Number* lambda, Number obj_value,const IpoptData* ip_data,IpoptCalculatedQuantities* ip_cq)
+{
+ finalX_ = (double*)malloc(sizeof(double) * numVars_ * 1);
+ for (Index i=0; i<numVars_; i++)
+ {
+ finalX_[i] = x[i];
+ }
+
+ finalObjVal_ = obj_value;
+ status_ = status;
+ iter_ = ip_data->iter_count();
+}
+
+
+const double * minuncNLP::getX()
+{
+ return finalX_;
+}
+
+const double * minuncNLP::getGrad()
+{
+ return finalGradient_;
+}
+
+const double * minuncNLP::getHess()
+{
+ return finalHessian_;
+}
+
+double minuncNLP::getObjVal()
+{
+ return finalObjVal_;
+}
+
+double minuncNLP::iterCount()
+{
+ return (double)iter_;
+}
+
+int minuncNLP::returnStatus()
+{
+ return status_;
+}
+
+}
+
+
+