summaryrefslogtreecommitdiff
path: root/tests/general_tests/fminbnd
diff options
context:
space:
mode:
authorHarpreet2016-02-24 16:22:06 +0530
committerHarpreet2016-02-24 16:22:06 +0530
commit03241d180c9d65fa1e75ceac4c257df44438a1ce (patch)
treeeb6e3875f136ec94ce138382adb90e925ff84750 /tests/general_tests/fminbnd
parent7996c2704975d61e03cfb4204cfb8e202367a448 (diff)
downloadFOSSEE-Optimization-toolbox-03241d180c9d65fa1e75ceac4c257df44438a1ce.tar.gz
FOSSEE-Optimization-toolbox-03241d180c9d65fa1e75ceac4c257df44438a1ce.tar.bz2
FOSSEE-Optimization-toolbox-03241d180c9d65fa1e75ceac4c257df44438a1ce.zip
fmincon examples added
Diffstat (limited to 'tests/general_tests/fminbnd')
-rw-r--r--tests/general_tests/fminbnd/fminbnd_f.sce15
-rw-r--r--tests/general_tests/fminbnd/fminbnd_lb1.sce18
-rw-r--r--tests/general_tests/fminbnd/fminbnd_lb2.sce18
-rw-r--r--tests/general_tests/fminbnd/fminbnd_lbub.sce19
-rw-r--r--tests/general_tests/fminbnd/fminbnd_logical1.sce38
-rw-r--r--tests/general_tests/fminbnd/fminbnd_logical2.sce38
-rw-r--r--tests/general_tests/fminbnd/fminbnd_options1.sce18
-rw-r--r--tests/general_tests/fminbnd/fminbnd_options2.sce18
-rw-r--r--tests/general_tests/fminbnd/fminbnd_options3.sce17
-rw-r--r--tests/general_tests/fminbnd/fminbnd_ub1.sce18
-rw-r--r--tests/general_tests/fminbnd/fminbnd_ub2.sce18
11 files changed, 235 insertions, 0 deletions
diff --git a/tests/general_tests/fminbnd/fminbnd_f.sce b/tests/general_tests/fminbnd/fminbnd_f.sce
new file mode 100644
index 0000000..96b08de
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_f.sce
@@ -0,0 +1,15 @@
+//Find x in R^6 such that:
+// Check if a user specifies function or not
+
+fun = [];
+x1 = [1,1,1,1,1,1];
+x2 = [6,6,6,6,6,6];
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminunc: Expected function for Objective
+//at line 148 of function fminunc called by :
+//[xopt,fopt,exitflag,output,gradient,hessian] = fminunc (fun, x0, options);
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_lb1.sce b/tests/general_tests/fminbnd/fminbnd_lb1.sce
new file mode 100644
index 0000000..3c60c1e
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_lb1.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check if a lower bound is empty or not
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [];
+x2 = [1,2];
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Lower Bound (2nd Parameter) cannot be empty
+//at line 177 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, lb, ub, options);
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_lb2.sce b/tests/general_tests/fminbnd/fminbnd_lb2.sce
new file mode 100644
index 0000000..f159657
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_lb2.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check if the user specifies correct lower bound
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1];
+x2 = [2];
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Objective function and x1 did not match
+//at line 193 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_lbub.sce b/tests/general_tests/fminbnd/fminbnd_lbub.sce
new file mode 100644
index 0000000..3a3ec52
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_lbub.sce
@@ -0,0 +1,19 @@
+//Find x in R^2 such that:
+// Check if Upper bound and lower bound is entered correctly
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [0.5,2.1];
+x2 = [1,2];
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Difference between Upper Bound and Lower bound should be atleast > 10^-6 for variable number= 2
+//at line 242 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
diff --git a/tests/general_tests/fminbnd/fminbnd_logical1.sce b/tests/general_tests/fminbnd/fminbnd_logical1.sce
new file mode 100644
index 0000000..87da61d
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_logical1.sce
@@ -0,0 +1,38 @@
+//Find x in R^2 such that:
+//An Example which results in exceeding Maximum Iterations
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [0,0];
+x2 = [1,2];
+options=list("MaxIter", [8], "CpuTime", [500],"TolX",[1e-6]);
+
+//Output
+//
+//Maximum Number of Iterations Exceeded. Output may not be optimal.
+// lambda =
+//
+// lower: [0.0026488,0.0024921]
+// upper: [8.873D-08,4.494D-08]
+// output =
+//
+// Iterations: 8
+// Cpu_Time: 0.012
+// Objective_Evaluation: 9
+// Dual_Infeasibility: 2.632D-12
+// Message: "Maximum Number of Iterations Exceeded. Output may not be optimal"
+// exitflag =
+//
+// 1
+// fopt =
+//
+// 0.0000033
+// xopt =
+//
+// 0.0013244
+// 0.0012460
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
diff --git a/tests/general_tests/fminbnd/fminbnd_logical2.sce b/tests/general_tests/fminbnd/fminbnd_logical2.sce
new file mode 100644
index 0000000..65ebee6
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_logical2.sce
@@ -0,0 +1,38 @@
+//Find x in R^2 such that:
+//An Example which results in exceeding Maximum CPU-Time
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [0,0];
+x2 = [1,2];
+options=list("MaxIter", [100], "CpuTime", [0.01],"TolX",[1e-6]);
+
+//Output
+//
+//Maximum CPU Time exceeded. Output may not be optimal.
+// lambda =
+//
+// lower: [0,0]
+// upper: [0,0]
+// output =
+//
+// Iterations: 3
+// Cpu_Time: 0.012
+// Objective_Evaluation: 4
+// Dual_Infeasibility: 9.406D-11
+// Message: "Maximum CPU Time exceeded. Output may not be optimal"
+// exitflag =
+//
+// 2
+// fopt =
+//
+// 0.
+// xopt =
+//
+// 0.0381891
+// 0.0353974
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
diff --git a/tests/general_tests/fminbnd/fminbnd_options1.sce b/tests/general_tests/fminbnd/fminbnd_options1.sce
new file mode 100644
index 0000000..bc98cae
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_options1.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check if a user specifies correct options or not
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1,2];
+x2 = [3,4];
+options=list("MaxIter", "", "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Value for Maximum Iteration should be a Constant
+//at line 261 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_options2.sce b/tests/general_tests/fminbnd/fminbnd_options2.sce
new file mode 100644
index 0000000..b4a9f13
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_options2.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check if a user specifies correct options or not
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1,2];
+x2 = [3,4];
+options=list("MaxIter", [1000], "CpuTime", "TolX",[1e-6]);
+
+//Error
+//fminbnd: Value for Maximum Cpu-time should be a Constant
+//at line 268 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_options3.sce b/tests/general_tests/fminbnd/fminbnd_options3.sce
new file mode 100644
index 0000000..5699cf9
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_options3.sce
@@ -0,0 +1,17 @@
+//Find x in R^2 such that:
+// Check if a user specifies correct options or not
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1,2];
+x2 = [3,4];
+options=list("MaxIter", [1000], "CpuTime", [100], "TolX", " ");
+
+//Error
+//fminbnd: Value for Tolerance should be a Constant
+//at line 275 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options);
+
diff --git a/tests/general_tests/fminbnd/fminbnd_ub1.sce b/tests/general_tests/fminbnd/fminbnd_ub1.sce
new file mode 100644
index 0000000..daf1487
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_ub1.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check if a upper bound is of correct size
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1,2];
+x2 = [1];
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Upper Bound and Lower Bound are not matching
+//at line 213 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
diff --git a/tests/general_tests/fminbnd/fminbnd_ub2.sce b/tests/general_tests/fminbnd/fminbnd_ub2.sce
new file mode 100644
index 0000000..82c446d
--- /dev/null
+++ b/tests/general_tests/fminbnd/fminbnd_ub2.sce
@@ -0,0 +1,18 @@
+//Find x in R^2 such that:
+// Check the type of Upperbound
+
+function y = fun(x)
+ y = x(1)^2 + x(2)^2;
+endfunction
+x1 = [1;2];
+x2 = list(2,3);
+options=list("MaxIter", [1500], "CpuTime", [500],"TolX",[1e-6]);
+
+//Error
+//fminbnd: Expected Vector/Scalar for Upper Bound Vector (3rd Parameter)
+//at line 199 of function fminbnd called by :
+//[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+
+
+[xopt,fopt,exitflag,output,lambda] = fminbnd (fun, x1, x2, options)
+