Optimoptions error: "Empty keys are not allowed in this container" (no number given)

What is the source of my error? I am running a program that calls optimoptions with the following command:
options = optimoptions(@fmincon,'Algorithm','sqp');
This results in the following errors:
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in Cure_main (line 36)
options = optimoptions(@fmincon,'Algorithm','sqp');
Cure_main.m is my main function. Prior to line 36, no other functions are yet called. Other members of my team can run the code, using copies of my files. They are using 2018a, I am using a newly installed copy of 2020a. I have confirmed that I can open optimoptions in my copy of matlab.
I have also checked that I have the appropriate toolbox:
>> license('inuse')
matlab
optimization_toolbox
I have not changed the path for anything in my matlab, other than adding the directory of my script files and the .txt that they use. I have tried changing @fmincon to 'fmincon', and had the same result.
The complete code is:
clc; clear all; close all;
format long;
global Atest T m;
d=load('1.txt');
m=1580;
Atest=d(:,2)*1.0;
T=d(:,1);
x=[
0.0106777326336
];
% I have removed a large number of commented-out value options here
options = optimoptions(@fmincon,'Algorithm','sqp');
There is more after this, but it is not necessary to reproduce the error.

18 commentaires

Following, I am having the same issue with optimoptions. My colleagues are able to run the script without any errors. I also have Matlab2020a.
Do you have the Global Optimization Toolbox installed when they do not, or the other way around?
If you do not mind doing some debugging work in R2020a, then
clear createSolverOptions %important for debugging
dbstop in createSolverOptions 67
options = optimoptions(@fmincon,'Algorithm','sqp');
It should stop at line 67 of createSolverOptions . At that point please examine
disp(hasGlobalOptimInstalled)
disp(solvernames)
disp(isGlobal)
disp({allClasses.Name})
My suspicion is that one of the solvernames is coming out empty, but I do not know at the moment what could be causing that.
Thank you, Walter! Unfortunately, by yesterday afternoon my deadline was looming, so I had uninstalled 2020a and reinstalled 2019b. On that build, the script works without issue.
For both setups I have had Global Optimization Toolbox installed, as did my coworkers. Odd. Unfortunately I don't have a lot of time, or I would keep investigating and do that debuging. It would be nice for us to futureproof this code.
Same issue here with a co-worker. Script works fine in 2016b and 2019b but not 2020a.
Caleb Peck
Caleb Peck le 7 Avr 2020
Modifié(e) : Caleb Peck le 7 Avr 2020
Walter, I tried to follow your steps (on R2020a) and your hunch was correct that solverNames is empty.
edit: I should say that I was also experiencing this issue which brought me to this thread!
Could you show us the values of solvernames and {allClasses.Name} ? Perhaps we can track down which solver is triggering the problem.
I have 'solverNames' as a 0x1 empty cell array; {allClasses.Name} is also empty, in fact the whole allClasses class is empty. My varargin is 'algorithm','sqp' in cells 1x1 and 1x2.
I should say that i've been manually stopping the code at line 67 of createSolverOptions only because I wasnt exactly sure where to include the three lines you posted earlier.
Did you reinstall the optimization toolkit? That's what solved it in my case.
I havent, I'll try that
Caleb Peck
Caleb Peck le 8 Avr 2020
Modifié(e) : Caleb Peck le 8 Avr 2020
@Alejandro that seems to have done the trick! Thanks for that.
If you are still having the problem, could you show the output of
matlabroot
meta.package.fromName('optim.options')
I'm not great with matlab, but I was able to just use the optimset function instead. Not sure if that will help anyone else!
hi all, I have a similar issue on the 2018b works fine on the 2020a not. The optimoptions string is this :
optimoptions('fsolve','Algorithm','trust-region-reflective','Display','None');
the error I get is this :
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in My_Galpha_integration_linear001 (line 16)
options = optimoptions('fsolve','Algorithm','trust-region-reflective','Display','None');
I ran this :
matlabroot
meta.package.fromName('optim.options')
but nothing changed.. any help please?
Please run the following commands and show us the output
matlabroot
info = meta.package.fromName('optim.options')
{info.FunctionList.Name}
These commands will not change anything on your system, but they will give us information that we need to go further in debugging the problem.
this is the output I get:
info = meta.package.fromName('optim.options')
{info.FunctionList.Name}
ans =
'C:\Program Files\MATLAB\R2020a'
info =
package with properties:
Name: 'optim.options'
Description: ''
DetailedDescription: ''
ClassList: [4×1 meta.class]
FunctionList: [10×1 meta.method]
PackageList: [1×1 meta.package]
ContainingPackage: [1×1 meta.package]
ans =
1×10 cell array
Columns 1 through 3
{'createSolverOpt…'} {'createLinkToSol…'} {'generateMultiAl…'}
Columns 4 through 6
{'replaceFinDiffR…'} {'getDefaultFinDi…'} {'getDisplayOptio…'}
Columns 7 through 9
{'getOptionDefaul…'} {'createNonConsta…'} {'generateMultiAl…'}
Column 10
{'generateSingleA…'}

Connectez-vous pour commenter.

Réponses (1)

I met the same problem with 2020a, I re-run the installer and added Global Optimization Toolbox into my installation procedure. It seems to have resolved the problem.

4 commentaires

I have the same problem and try this method, it works perfectly.
Worked for me too, thanks!
One would hope the error message in Matlab would say something like "missing toolbox" instead of the current gibberish that doesn't hint at that at all...
It works, thank you.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by