Dear Mr. Zimmerman and Mr. Ahmed, Thank you for the reply. I modified the codes in related function. The test is done.
========================================== >> test_matpower t_loadcase..........ok t_ext2int2ext.......ok t_jacobian..........ok t_hessian...........ok t_totcost...........ok t_modcost...........ok t_hasPQcap..........ok t_mips..............ok t_qps_matpower......ok (180 of 288 skipped) t_pf................ok t_opf_mips..........ok t_opf_mips_sc.......ok t_opf_dc_mips.......ok t_opf_dc_mips_sc....ok t_opf_dc_ot.........ok t_opf_userfcns......ok t_runopf_w_res......ok t_dcline............ok t_makePTDF..........ok t_makeLODF..........ok t_total_load........ok t_scale_load........ok t_off2case..........ok t_auction_mips......ok t_runmarket.........ok All tests successful (1725 passed, 180 skipped of 1905) Elapsed time 31.11 seconds. ========================================== Best Wishes, Ehsan On Tue, Jul 25, 2017 at 4:19 PM, Ray Zimmerman <[email protected]> wrote: > Sorry, something got messed up with the attachment on my previous reply, > so I’m resending. > > Hi Ehsan, > > It appears that MATLAB 2017a changed how it handles the quadprog() < > https://www.mathworks.com/help/optim/ug/quadprog.html> return argument > lambda in cases when the problem is infeasible. The qps_ot() wrapper in > MATPOWER 4.1 assumes lambda is a struct with certain fields (which may be > empty), but in MATLAB R2017a, lambda itself can actually be empty and > attempting to access the fields, as qps_ot() does, results in an error. > > Hopefully, using the attached patched version of qps_ot() will resolve the > issue for you. > > Ray > > > > On Jul 25, 2017, at 4:20 AM, Ehsan Hejri <[email protected]> > wrote: > > > > Hi everybody, > > > > I am using MATLAB R2017a and I am going to install matpower 4.1 (to use > MatACDC 1.0 i can only work with this version) on my computer. > > After adding matpower 4.1 to the path and running test_matpower > > I am receiving this error. > > > > ====================================== > > >> test_matpower > > t_loadcase..........ok > > t_ext2int2ext.......ok > > t_jacobian..........ok > > t_hessian...........ok > > t_totcost...........ok > > t_modcost...........ok > > t_hasPQcap..........ok > > t_mips..............ok > > t_qps_matpower......Struct contents reference from a non-struct array > object. > > > > Error in qps_ot (line 260) > > kl = find(lam.eqlin < 0); TCL MERGE ERROR ( 07/25/2017 10:19:38 ): > "extra characters after close-quote" > OutmailID: 121677364, List: 'matpower-l', MemberID: 78655604 > SCRIPT: "lower bound binding > > Error in qps_matpower (line 241) > > qps_ot(H, c, A, l, u, xmin, xmax, x0, opt); > > Error in > t_qps_matpower (line 157) > [x, f, s, out, lam] = qps_matpower(p); > > > Error in t_run_tests (line 79) > feval( test_names{k}, ~verbose ); > > > Error in test_matpower (line 135) > t_run_tests( tests, verbose ); > > ====================================== > > I would appreciate to help me > to solve this problem. > > Best Regards, > Ehsan > --Apple-Mail=_08033BAE-3119-49E4-B6A0-56AA59155307 Content-Type: > multipart/mixed; boundary="Apple-Mail=_0D52D5D6-6203-4936-9DC3-DF5537AA51C7" > --Apple-Mail=_0D52D5D6-6203-4936-9DC3-DF5537AA51C7 > Content-Transfer-Encoding: quoted-printable Content-Type: text/html; > charset="utf-8" <html><head><meta http-equiv="Content-Type" > content="text/html charset=utf-8"></head><body style="word-wrap: > break-word; -webkit-nbsp-mode: space; -webkit-line-break: > after-white-space;" class=""><i class="">Sorry, something got messed up > with the attachment on my previous reply, so I’m resending.</i><div > class=""><br class=""></div><div class="">Hi Ehsan,<div class=""><br > class=""></div><div class="">It appears that MATLAB 2017a changed how it > handles the <a href="https://www.mathworks. > com/help/optim/ug/quadprog.html" class=""><font face="Courier" > class="">quadprog()</font></a> return argument <font > face="Courier" class="">lambda</font> in cases when the problem is > infeasible. The <font face="Courier" > class="">qps_ot()</font> wrapper > in MATPOWER 4.1 assumes <span class="" style="font-family: > Courier;">lambda</span> is a struct with certain fields (which may > be empty), but in MATLAB R2017a, lambda itself can actually be empty and > attempting to access the fields, as <span class="" style="font-family: > Courier;">qps_ot()</span> does, results in an error.</div><div > class=""><br class=""></div><div class="">Hopefully, using the attached > patched version of <font face="Courier" > class="">qps_ot()</font> will > resolve the issue for you.</div><div class=""><br class=""></div><div > class=""> Ray</div></div><div class=""><br class=""></div><div > class=""><br class=""><div><blockquote type="cite" class=""><div > class="">On Jul 25, 2017, at 4:20 AM, Ehsan Hejri <<a href="mailto: > [email protected]" class="">[email protected]</a>> > wrote:</div><br class="Apple-interchange-newline"><div class=""><div > dir="ltr" class="">Hi everybody,<div class=""><br class=""><div class="">I > am using MATLAB R2017a and I am going to install matpower 4.1 (to use > MatACDC 1.0 i can only work with this version) on my > computer. </div><div class="">After adding matpower 4.1 to the path > and running test_matpower</div><div class="">I am receiving this > error. </div><div class=""><br class=""></div><div > class="">======================================</div><div > class=""> >> test_matpower</div><div > class="">t_loadcase..........ok</div><div > class="">t_ext2int2ext.......ok</div><div > class="">t_jacobian..........ok</div><div > class="">t_hessian...........ok</div><div > class="">t_totcost...........ok</div><div > class="">t_modcost...........ok</div><div > class="">t_hasPQcap..........ok</div><div > class="">t_mips..............ok</div><div > class="">t_qps_matpower......Struct contents reference from a non-struct > array object.</div><div class=""><br class=""></div><div class="">Error in > qps_ot (line 260)</div><div class="">kl = find(lam.eqlin < 0); " > lower bound binding</div><div class=""><br class=""></div><div > class="">Error in qps_matpower (line 241)</div><div class=""> > qps_ot(H, c, A, l, u, xmin, xmax, x0, > opt);</div><div class=""><br class=""></div><div class="">Error in > t_qps_matpower (line 157)</div><div class=""> > [x, f, s, out, lam] = qps_matpower(p);</div><div class=""><br > class=""></div><div class="">Error in t_run_tests (line 79)</div><div > class=""> feval( test_names{k}, ~verbose );</div><div > class=""><br class=""></div><div class="">Error in test_matpower (line > 135)</div><div class="">t_run_tests( tests, verbose );</div><div > class="">======================================</div><div class=""><br > class=""></div><div class="">I would appreciate to help me to solve this > problem. </div></div><div class=""><br class=""></div><div > class="">Best Regards,<br class="">Ehsan</div></div> > </div></blockquote></div><div class=""><br class=""></div></div></body></ > html> > --Apple-Mail=_0D52D5D6-6203-4936-9DC3-DF5537AA51C7 > Content-Disposition: attachment; > filename="qps_ot.m" > Content-Type: application/octet-stream; > name="qps_ot.m" > Content-Transfer-Encoding: 7bit > > function [x, f, eflag, output, lambda] = qps_ot(H, c, A, l, u, xmin, xmax, > x0, opt) > %QPS_OT Quadratic Program Solver based on QUADPROG/LINPROG. > % [X, F, EXITFLAG, OUTPUT, LAMBDA] = ... > % QPS_OT(H, C, A, L, U, XMIN, XMAX, X0, OPT) > % A wrapper function providing a MATPOWER standardized interface for > using > % QUADPROG or LINPROG from the Optimization Toolbox to solve the > % following QP (quadratic programming) problem: > % > % min 1/2 X'*H*X + C'*X > % X > % > % subject to > % > % L <= A*X <= U (linear constraints) > % XMIN <= X <= XMAX (variable bounds) > % > % Inputs (all optional except H, C, A and L): > % H : matrix (possibly sparse) of quadratic cost coefficients > % C : vector of linear cost coefficients > % A, L, U : define the optional linear constraints. Default > % values for the elements of L and U are -Inf and Inf, > % respectively. > % XMIN, XMAX : optional lower and upper bounds on the > % X variables, defaults are -Inf and Inf, respectively. > % X0 : optional starting value of optimization vector X > % OPT : optional options structure with the following fields, > % all of which are also optional (default values shown in > % parentheses) > % verbose (0) - controls level of progress output displayed > % 0 = no progress output > % 1 = some progress output > % 2 = verbose progress output > % max_it (0) - maximum number of iterations allowed > % 0 = use algorithm default > % ot_opt - options struct for QUADPROG/LINPROG, values in > % verbose and max_it override these options > % PROBLEM : The inputs can alternatively be supplied in a single > % PROBLEM struct with fields corresponding to the input arguments > % described above: H, c, A, l, u, xmin, xmax, x0, opt > % > % Outputs: > % X : solution vector > % F : final objective function value > % EXITFLAG : QUADPROG/LINPROG exit flag > % (see QUADPROG and LINPROG documentation for details) > % OUTPUT : QUADPROG/LINPROG output struct > % (see QUADPROG and LINPROG documentation for details) > % LAMBDA : struct containing the Langrange and Kuhn-Tucker > % multipliers on the constraints, with fields: > % mu_l - lower (left-hand) limit on linear constraints > % mu_u - upper (right-hand) limit on linear constraints > % lower - lower bound on optimization variables > % upper - upper bound on optimization variables > % > % Note the calling syntax is almost identical to that of QUADPROG > % from MathWorks' Optimization Toolbox. The main difference is that > % the linear constraints are specified with A, L, U instead of > % A, B, Aeq, Beq. > % > % Calling syntax options: > % [x, f, exitflag, output, lambda] = ... > % qps_ot(H, c, A, l, u, xmin, xmax, x0, opt) > % > % x = qps_ot(H, c, A, l, u) > % x = qps_ot(H, c, A, l, u, xmin, xmax) > % x = qps_ot(H, c, A, l, u, xmin, xmax, x0) > % x = qps_ot(H, c, A, l, u, xmin, xmax, x0, opt) > % x = qps_ot(problem), where problem is a struct with fields: > % H, c, A, l, u, xmin, xmax, x0, opt > % all fields except 'c', 'A' and 'l' or 'u' are > optional > % x = qps_ot(...) > % [x, f] = qps_ot(...) > % [x, f, exitflag] = qps_ot(...) > % [x, f, exitflag, output] = qps_ot(...) > % [x, f, exitflag, output, lambda] = qps_ot(...) > % > % > % Example: (problem from from http://www.jmu.edu/docs/ > sasdoc/sashtml/iml/chap8/sect12.htm) > % H = [ 1003.1 4.3 6.3 5.9; > % 4.3 2.2 2.1 3.9; > % 6.3 2.1 3.5 4.8; > % 5.9 3.9 4.8 10 ]; > % c = zeros(4,1); > % A = [ 1 1 1 1; > % 0.17 0.11 0.10 0.18 ]; > % l = [1; 0.10]; > % u = [1; Inf]; > % xmin = zeros(4,1); > % x0 = [1; 0; 0; 1]; > % opt = struct('verbose', 2); > % [x, f, s, out, lambda] = qps_ot(H, c, A, l, u, xmin, [], x0, opt); > % > % See also QUADPROG, LINPROG. > > % MATPOWER > % $Id: qps_ot.m,v 1.13 2011/09/09 15:26:09 cvs Exp $ > % by Ray Zimmerman, PSERC Cornell > % Copyright (c) 2010-2011 by Power System Engineering Research Center > (PSERC) > % > % This file is part of MATPOWER. > % See http://www.pserc.cornell.edu/matpower/ for more info. > % > % MATPOWER is free software: you can redistribute it and/or modify > % it under the terms of the GNU General Public License as published > % by the Free Software Foundation, either version 3 of the License, > % or (at your option) any later version. > % > % MATPOWER is distributed in the hope that it will be useful, > % but WITHOUT ANY WARRANTY; without even the implied warranty of > % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > % GNU General Public License for more details. > % > % You should have received a copy of the GNU General Public License > % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. > % > % Additional permission under GNU GPL version 3 section 7 > % > % If you modify MATPOWER, or any covered work, to interface with > % other modules (such as MATLAB code and MEX-files) available in a > % MATLAB(R) or comparable environment containing parts covered > % under other licensing terms, the licensors of MATPOWER grant > % you additional permission to convey the resulting work. > > %% check for Optimization Toolbox > % if ~have_fcn('quadprog') > % error('qps_ot: requires the Optimization Toolbox'); > % end > > %%----- input argument handling ----- > %% gather inputs > if nargin == 1 && isstruct(H) %% problem struct > p = H; > if isfield(p, 'opt'), opt = p.opt; else, opt = []; end > if isfield(p, 'x0'), x0 = p.x0; else, x0 = []; end > if isfield(p, 'xmax'), xmax = p.xmax; else, xmax = []; end > if isfield(p, 'xmin'), xmin = p.xmin; else, xmin = []; end > if isfield(p, 'u'), u = p.u; else, u = []; end > if isfield(p, 'l'), l = p.l; else, l = []; end > if isfield(p, 'A'), A = p.A; else, A = []; end > if isfield(p, 'c'), c = p.c; else, c = []; end > if isfield(p, 'H'), H = p.H; else, H = []; end > else %% individual args > if nargin < 9 > opt = []; > if nargin < 8 > x0 = []; > if nargin < 7 > xmax = []; > if nargin < 6 > xmin = []; > end > end > end > end > end > > %% define nx, set default values for missing optional inputs > if isempty(H) || ~any(any(H)) > if isempty(A) && isempty(xmin) && isempty(xmax) > error('qps_ot: LP problem must include constraints or variable > bounds'); > else > if ~isempty(A) > nx = size(A, 2); > elseif ~isempty(xmin) > nx = length(xmin); > else % if ~isempty(xmax) > nx = length(xmax); > end > end > else > nx = size(H, 1); > end > if isempty(c) > c = zeros(nx, 1); > end > if ~isempty(A) && (isempty(l) || all(l == -Inf)) && ... > (isempty(u) || all(u == Inf)) > A = sparse(0,nx); %% no limits => no linear constraints > end > nA = size(A, 1); %% number of original linear constraints > if isempty(u) %% By default, linear inequalities are ... > u = Inf * ones(nA, 1); %% ... unbounded above and ... > end > if isempty(l) > l = -Inf * ones(nA, 1); %% ... unbounded below. > end > if isempty(xmin) %% By default, optimization variables are > ... > xmin = -Inf * ones(nx, 1); %% ... unbounded below and ... > end > if isempty(xmax) > xmax = Inf * ones(nx, 1); %% ... unbounded above. > end > if isempty(x0) > x0 = zeros(nx, 1); > end > > %% default options > if ~isempty(opt) && isfield(opt, 'verbose') && ~isempty(opt.verbose) > verbose = opt.verbose; > else > verbose = 0; > end > if ~isempty(opt) && isfield(opt, 'max_it') && ~isempty(opt.max_it) > max_it = opt.max_it; > else > max_it = 0; > end > > %% split up linear constraints > ieq = find( abs(u-l) <= eps ); %% equality > igt = find( u >= 1e10 & l > -1e10 ); %% greater than, unbounded above > ilt = find( l <= -1e10 & u < 1e10 ); %% less than, unbounded below > ibx = find( (abs(u-l) > eps) & (u < 1e10) & (l > -1e10) ); > Ae = A(ieq, :); > be = u(ieq); > Ai = [ A(ilt, :); -A(igt, :); A(ibx, :); -A(ibx, :) ]; > bi = [ u(ilt); -l(igt); u(ibx); -l(ibx)]; > > %% grab some dimensions > nlt = length(ilt); %% number of upper bounded linear inequalities > ngt = length(igt); %% number of lower bounded linear inequalities > nbx = length(ibx); %% number of doubly bounded linear inequalities > > %% set up options > if ~isempty(opt) && isfield(opt, 'ot_opt') && ~isempty(opt.ot_opt) > ot_opt = opt.ot_opt; > else > if isempty(H) || ~any(any(H)) > ot_opt = optimset('linprog'); > else > ot_opt = optimset('quadprog'); > if have_fcn('quadprog_ls') > ot_opt = optimset(ot_opt, 'Algorithm', > 'interior-point-convex'); > else > ot_opt = optimset(ot_opt, 'LargeScale', 'off'); > end > end > end > if max_it > ot_opt = optimset(ot_opt, 'MaxIter', max_it); > end > if verbose > 1 > ot_opt = optimset(ot_opt, 'Display', 'iter'); %% seems to be same as > 'final' > elseif verbose == 1 > ot_opt = optimset(ot_opt, 'Display', 'final'); > else > ot_opt = optimset(ot_opt, 'Display', 'off'); > end > > %% call the solver > if isempty(H) || ~any(any(H)) > [x, f, eflag, output, lam] = ... > linprog(c, Ai, bi, Ae, be, xmin, xmax, x0, ot_opt); > else > [x, f, eflag, output, lam] = ... > quadprog(H, c, Ai, bi, Ae, be, xmin, xmax, x0, ot_opt); > end > > %% repackage lambdas > if isempty(x) > x = NaN(nx, 1); > end > if isempty(lam) || (isempty(lam.eqlin) && isempty(lam.ineqlin) && ... > isempty(lam.lower) && isempty(lam.upper)) > lambda = struct( ... > 'mu_l', NaN(nA, 1), ... > 'mu_u', NaN(nA, 1), ... > 'lower', NaN(nx, 1), ... > 'upper', NaN(nx, 1) ... > ); > else > kl = find(lam.eqlin < 0); %% lower bound binding > ku = find(lam.eqlin > 0); %% upper bound binding > > mu_l = zeros(nA, 1); > mu_l(ieq(kl)) = -lam.eqlin(kl); > mu_l(igt) = lam.ineqlin(nlt+(1:ngt)); > mu_l(ibx) = lam.ineqlin(nlt+ngt+nbx+(1:nbx)); > > mu_u = zeros(nA, 1); > mu_u(ieq(ku)) = lam.eqlin(ku); > mu_u(ilt) = lam.ineqlin(1:nlt); > mu_u(ibx) = lam.ineqlin(nlt+ngt+(1:nbx)); > > lambda = struct( ... > 'mu_l', mu_l, ... > 'mu_u', mu_u, ... > 'lower', lam.lower(1:nx), ... > 'upper', lam.upper(1:nx) ... > ); > end > > --Apple-Mail=_0D52D5D6-6203-4936-9DC3-DF5537AA51C7 > Content-Transfer-Encoding: 7bit > Content-Type: text/html; > charset="us-ascii" > > <html><head><meta http-equiv="Content-Type" content="text/html > charset=us-ascii"></head><body style="word-wrap: break-word; > -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" > class=""><div class=""></div></body></html> > --Apple-Mail=_0D52D5D6-6203-4936-9DC3-DF5537AA51C7-- >
