1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
|