Skip to content

Commit 23bb2ef

Browse files
author
Elizabeth Wong
committed
specs returns true info; update and fix comments
1 parent f541d8a commit 23bb2ef

File tree

7 files changed

+22
-37
lines changed

7 files changed

+22
-37
lines changed

matlab/lpopt.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function [x,obj,INFO,output,lambda,states] = lpopt(c, x0, xl, xu, A, al, au, varargin)
2-
% function [x,obj,INFO,output,lambda,states] = lpopt(c, x0, xl, xu, A, al, au, varargin)
1+
function [x,obj,info,output,lambda,states] = lpopt(c, x0, xl, xu, A, al, au, varargin)
2+
% function [x,obj,info,output,lambda,states] = lpopt(c, x0, xl, xu, A, al, au, varargin)
33
%
44
% This function solves the linear optimization problem:
55
% minimize:
@@ -21,7 +21,7 @@
2121
% [] = lpopt(c, x0, xl, xu, A, al, au, states, lambda)
2222
% [] = lpopt(c, x0, xl, xu, A, al, au, states, lambda, options)
2323
%
24-
% [x,obj,INFO,output,lambda,states] = lpopt(...)
24+
% [x,obj,info,output,lambda,states] = lpopt(...)
2525
%
2626
%
2727
% INPUT:
@@ -45,7 +45,7 @@
4545
%
4646
% obj is the final objective value
4747
%
48-
% exitFlag is the exit flag returned by DQOPT
48+
% info is the exit flag returned by the solver
4949
%
5050
% output is a structure containing run information --
5151
% output.iterations is the total number of iterations
@@ -152,14 +152,14 @@
152152
c = colvec(c,'c',1,0);
153153

154154
userHx = 0;
155-
[x,obj,INFO,itn,y,state] = sqoptmex(solveOpt, start, probName, ...
155+
[x,obj,info,itn,y,state] = sqoptmex(solveOpt, start, probName, ...
156156
m, n, userHx, c, ...
157157
x0, xl, xu, xstate, xmul, ...
158158
neA, indA, locA, valA, al, au, astate, amul);
159159

160160
% Set output
161161
output.iterations = itn;
162-
output.info = INFO;
162+
output.info = info;
163163

164164
zero = zeros(n,1);
165165
states.x = state(1:n);

matlab/snspec.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% Causes snopt to read its optional parameters from the named file.
33
% The format of this file is described in the snopt documentation.
44
%
5-
% Returns 0 if successful, and a positive number otherwise.
5+
% Returns 101 or 107 if successful.
66
function inform = snspec( filename )
77

88
snoption = 9;

matlab/sqopt.m

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function [x,obj,INFO,output,lambda,states] = sqopt(Hx, c, x0, xl, xu, A, al, au, varargin)
2-
% function [x,obj,INFO,output,lambda,states] = sqopt(Hx, c, x0, xl, xu, A, al, au, varargin)
1+
function [x,obj,info,output,lambda,states] = sqopt(Hx, c, x0, xl, xu, A, al, au, varargin)
2+
% function [x,obj,info,output,lambda,states] = sqopt(Hx, c, x0, xl, xu, A, al, au, varargin)
33
%
44
% This function solves the quadratic optimization problem:
55
% minimize:
@@ -22,14 +22,15 @@
2222
% [] = sqopt(Hx, c, x0, xl, xu, A, al, au, states, lambda)
2323
% [] = sqopt(Hx, c, x0, xl, xu, A, al, au, states, lambda, options)
2424
%
25-
% [x,obj,INFO,output,lambda,states] = sqopt(...)
25+
% [x,obj,info,output,lambda,states] = sqopt(...)
2626
%
2727
%
2828
% INPUT:
2929
% x0 is the initial guess for x
3030
%
3131
% Hx is a Matlab function that computes H*x for a given x.
32-
% Hx can be a Matlab function handle or a string
32+
% Hx can be a Matlab function handle or a string. If the
33+
% problem is an LP (H = 0), then set Hx = 0 (or call lpopt).
3334
%
3435
% c is the linear term of the quadratic objective
3536
%
@@ -49,7 +50,7 @@
4950
%
5051
% obj is the final objective value
5152
%
52-
% exitFlag is the exit flag returned by DQOPT
53+
% info is the exit flag returned by the solver
5354
%
5455
% output is a structure containing run information --
5556
% output.iterations is the total number of iterations
@@ -163,14 +164,14 @@
163164
au = colvec(au,'au',1,m);
164165
c = colvec(c,'c',1,0);
165166

166-
[x,obj,INFO,itn,y,state] = sqoptmex(solveOpt, start, probName, ...
167+
[x,obj,info,itn,y,state] = sqoptmex(solveOpt, start, probName, ...
167168
m, n, userHx, c, ...
168169
x0, xl, xu, xstate, xmul, ...
169170
neA, indA, locA, valA, al, au, astate, amul);
170171

171172
% Set output
172173
output.iterations = itn;
173-
output.info = INFO;
174+
output.info = info;
174175

175176
zero = zeros(n,1);
176177
states.x = state(1:n);

matlab/sqspec.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% Causes sqopt to read its optional parameters from the named file.
33
% The format of this file is described in the sqopt documentation.
44
%
5-
% Returns 0 if successful, and a positive number otherwise.
5+
% Returns 101 or 107 if successful.
66
function inform = sqspec( filename )
77

88
snoption = 9;

mex/snmex.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ subroutine checkCol(pm, n, name)
126126
m = mxGetN(pm)
127127
if (m /= n) then
128128
write(str,100) name, m, n
129-
call mexErrMsgTxt (str)
129+
call mexErrMsgIdAndTxt('SNOPT:InputArgs',str)
130130
end if
131131

132132
return
@@ -151,7 +151,7 @@ subroutine checkRow(pm, n, name)
151151
m = mxGetM(pm)
152152
if (m /= n) then
153153
write(str,100) name, m, n
154-
call mexErrMsgTxt (str)
154+
call mexErrMsgIdAndTxt('SNOPT:InputArgs',str)
155155
end if
156156

157157
return

mex/snoptmex.F90

+3-10
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ subroutine snmxSolve (nlhs, plhs, nrhs, prhs)
279279
if (mxIsNumeric(prhs(3)) /= 1) then
280280
! Check if STOP functions is actually a function
281281
if (mxIsClass(prhs(3), 'function_handle') /= 1) &
282-
call mexErrMsgIdAndTxt('DNOPT:INputArgs','Wrong input type for dnSTOP')
282+
call mexErrMsgIdAndTxt('SNOPT:INputArgs','Wrong input type for snSTOP')
283283
stopHandle = mxDuplicateArray(prhs(3))
284284
end if
285285

@@ -289,7 +289,7 @@ subroutine snmxSolve (nlhs, plhs, nrhs, prhs)
289289
!-----------------------------------------------------------------------------
290290
probName = ''
291291
if (mxIsChar(prhs(4)) /= 1) &
292-
call mexErrMsgIdAndTxt('DNOPT:InputArg','Wrong input type for problem name')
292+
call mexErrMsgIdAndTxt('SNOPT:InputArg','Wrong input type for problem name')
293293

294294
if (mxGetN(prhs(4)) > 0) then
295295
dimx = min(8,mxGetN(prhs(4)))
@@ -785,14 +785,7 @@ subroutine snmxSpecs(nlhs, plhs, nrhs, prhs)
785785
rewind (iSpecs)
786786
close(iSpecs)
787787

788-
! snSpec will return info == 101 or 107 if successful
789-
! The matlab version returns 0 if successful
790-
if (info == 101 .or. info == 107) then
791-
rvalue = 0
792-
else
793-
rvalue = 1
794-
end if
795-
788+
rvalue = info
796789
plhs(1) = mxCreateDoubleScalar(rvalue)
797790

798791
end subroutine snmxSpecs

mex/sqoptmex.F90

+1-10
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ subroutine sqmxSolve(nlhs, plhs, nrhs, prhs)
261261
m = mxGetScalar(prhs(4))
262262
n = mxGetScalar(prhs(5))
263263

264-
call check('SQOPT', n, m)
265-
266264
nnH = n
267265
neA = mxGetScalar(prhs(13))
268266
ncObj = mxGetM(prhs(7))
@@ -571,14 +569,7 @@ subroutine snmxSpecs(nlhs, plhs, nrhs, prhs)
571569
rewind (iSpecs)
572570
close(iSpecs)
573571

574-
! sqSpec will return info == 101 or 107 if successful
575-
! The matlab version returns 0 if successful
576-
if (info == 101 .or. info == 107) then
577-
rvalue = 0
578-
else
579-
rvalue = 1
580-
end if
581-
572+
rvalue = info
582573
plhs(1) = mxCreateDoubleScalar (rvalue)
583574

584575
end subroutine snmxSpecs

0 commit comments

Comments
 (0)