Optimoptions error: "Empty keys are not allowed in this container" (no number given)
Afficher commentaires plus anciens
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
Alan Salek
le 26 Mar 2020
Following, I am having the same issue with optimoptions. My colleagues are able to run the script without any errors. I also have Matlab2020a.
Walter Roberson
le 26 Mar 2020
Do you have the Global Optimization Toolbox installed when they do not, or the other way around?
Walter Roberson
le 26 Mar 2020
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.
Geoffrey Rivers
le 27 Mar 2020
David
le 3 Avr 2020
Same issue here with a co-worker. Script works fine in 2016b and 2019b but not 2020a.
Walter Roberson
le 3 Avr 2020
David, would it be possible to do some investigation along the lines I describe in https://www.mathworks.com/matlabcentral/answers/512878-optimoptions-error-empty-keys-are-not-allowed-in-this-container-no-number-given#comment_816097
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!
Walter Roberson
le 8 Avr 2020
Could you show us the values of solvernames and {allClasses.Name} ? Perhaps we can track down which solver is triggering the problem.
Caleb Peck
le 8 Avr 2020
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.
Alejandro Graziano
le 8 Avr 2020
Did you reinstall the optimization toolkit? That's what solved it in my case.
Caleb Peck
le 8 Avr 2020
I havent, I'll try that
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.
Walter Roberson
le 8 Avr 2020
If you are still having the problem, could you show the output of
matlabroot
meta.package.fromName('optim.options')
Alejandro Graziano
le 8 Avr 2020
Great!
Sarah Shackleton
le 8 Avr 2020
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!
Francescogiuseppe Morabito
le 1 Mai 2020
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?
Walter Roberson
le 1 Mai 2020
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.
Francescogiuseppe Morabito
le 1 Mai 2020
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…'}
Réponses (1)
Nick Zhi
le 8 Mai 2020
15 votes
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
ZIJING MO
le 17 Mai 2020
I have the same problem and try this method, it works perfectly.
Martin Sjöberg
le 12 Sep 2020
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...
bd l
le 17 Sep 2020
It works, thank you.
Arash Allahyari
le 11 Fév 2022
thanks
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!