Skip to content

Bug: snopt interface for problems with "few" constraints #1459

Description

@hel-fried

Dear Johan,

I am currently toying with snopt and yalmip and stumbled upon a dimension issue for problems with "few" constraints.

Example:

x = sdpvar(2,1)

obj = 0.5*(100*(x(2)-x(1)^2)^2 + (1-x(1))^2)
c = [-0 <= x <= 2]

optimize(c, obj, sdpsettings('solver', 'snopt', 'debug', 1))`

which yields on my installation (linux, Yalmip 20230622):

Error using snoptmex
iGfun has incorrect column dimension     2.  Should be length     1

Error in solve_snopt (line 17)
 xstate,Fstate,itn,mjritn] = snoptmex(mexopt, ...
                             ^^^^^^^^^^^^^^^^^^^^
Error in snopt (line 465)
 xstate,Fstate,output] = solve_snopt(istart, stopFun, name, ...
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in callsnopt (line 89)
    [xout,F,inform,xmul,Fmul] = snopt(x0, xlow, xupp, xmul, xstate,Flow, Fupp, Fmul, Fstate, usrf,ObjAdd, ObjRow,A,G,model.options.snopt);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in solvesdp (line 420)
    eval(['output = ' solver.call '(interfacedata);']);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in optimize (line 31)
[varargout{1:nargout}] = solvesdp(varargin{:});
                         ^^^^^^^^^^^^^^^^^^^^^

I haven't fully looked into the root cause but I think iGfun should be transposed in certain cases. Without really knowing what I'm doing I hacked the following two lines into snopt.m

if size(iGfun,1) == 1
    iGfun = iGfun'
    jGvar = jGvar'
end

which did the trick for me...

Best
Helfried

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions