Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hel-fried opened this issue Jan 14, 2025 · 1 comment
Open

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

hel-fried opened this issue Jan 14, 2025 · 1 comment

Comments

@hel-fried
Copy link

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

@hel-fried hel-fried changed the title Bug: Snop interface for problem with few constraints Bug: Snop interface for problems with "few" constraints Jan 14, 2025
@hel-fried hel-fried changed the title Bug: Snop interface for problems with "few" constraints Bug: snopt interface for problems with "few" constraints Jan 14, 2025
@johanlofberg johanlofberg self-assigned this Jan 15, 2025
@johanlofberg
Copy link
Member

Confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants