I am getting the error message mentioned in the title while executing following line
opts = optimoptions('fmincon','Algorithm','interior-point');
I tried setting the default path through
restoredefaultpath
savepath
rehash toolboxcache
Still getting the same error. Can someone help?
Thanks

8 件のコメント

Ameer Hamza
Ameer Hamza 2020 年 11 月 4 日
Error is causes inside the exception handler. Can you post the complete error message? Also, run the following line in command window
dbstop if caught error
and run your code again. The code will automatically halt when the error occurs and open a file. Please tell name of that file.
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 4 日
C:\Program Files\MATLAB\R2020a\toolbox\shared\optimlib\+optim\+options\Fmincon.m
This is the file name where the code halts.
Also the complete error message is as follows-
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in Main (line 47)
opts = optimoptions('fmincon','Algorithm','interior-point');
Mario Malic
Mario Malic 2020 年 11 月 4 日
Do you have one set of options, and then you're calling another ones?
Is this the complete error message?
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
I have only one set of options. Infact since 'interior-point' is the default option for algorithm, I also tried the same command without any options as
opts = optimoptions('fmincon');
But still I get the same error.
Mario Malic
Mario Malic 2020 年 11 月 5 日
Try this example, if you can't open it, here's link
openExample('optim/NondefaultOptionsfminconExample')
Does it report error, if it does, then there might be something wrong with your MATLAB files.
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
When I tried this example, I got following error-
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "optim".
Error in findExample (line 18)
componentExamplesDir = exampleUtils.componentExamplesDir(component);
Error in openExample (line 30)
metadata = findExample(exampleId);
Does that mean I need to install MATLAB again on my computer?
Mario Malic
Mario Malic 2020 年 11 月 5 日
Get the code from link and try it.
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
I tried following code as you suggested
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
fun = @(x)100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
A = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
nonlcon = @unitdisk;
x0 = [0,0];
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
with the unitdisk defined in other file with same name as
function [c,ceq] = unitdisk(x)
c = x(1)^2 + x(2)^2 - 1;
ceq = [];
Getting the following error
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in problem (line 1)
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
Can you figure out what must be going wrong?
Thanks for spending your time on my problem

サインインしてコメントする。

 採用された回答

VBBV
VBBV 2020 年 11 月 5 日
編集済み: VBBV 2020 年 11 月 5 日

0 投票

%if true
% code
% end
opts = optimoptions(@fmincon,'Algorithm','interior-point');
Try function handle for passing solver name

11 件のコメント

Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
Tried your suggestion, still getting the same error
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in Main (line 47)
opts = optimoptions(@fmincon,'Algorithm','interior-point');
Following are the two lines of code where I am trying to use this
opts = optimoptions(@fmincon,'Algorithm','interior-point');
[C, SSE] = fmincon(@subfile,[1, 1, 1, 1, 1],[],[],[],[],[0, 0, 0, 0, 0.8],[10 10 10 10 0.8],[],opts,x_b,x_m, NCLD_EXP); % for CLD2
Can you see any problem?
Thanks
VBBV
VBBV 2020 年 11 月 5 日
編集済み: VBBV 2020 年 11 月 5 日
Many input arguments for fmincon
Specify lower and upper bound values, they cant be empty [] []
Use opts as last argument of fmincon function
What is NCLD_EXP ? Did you define the function @subfile before
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
  1. I have defined function @subfile before
  2. I tried putting opts at the end as last argument with no success
  3. In my arguments the four [ ] are given in order to indicate that there is no linear or nonlinear constraints
  4. the lower bounds are [0 0 0 0 0.8] and upper bounds are [10 10 10 10 0.8]
  5. I tried executing the code by removing x_b,x_m, NCLD_EXP (which were the parameters in @subfile) as
[C, SSE] = fmincon(@subfile,[1, 1, 1, 1, 1],[],[],[],[],[0, 0, 0, 0, 0.8],[10 10 10 10 0.8],opts);
again without any success
Any suggestions? Thanks
Mario Malic
Mario Malic 2020 年 11 月 5 日
[C, SSE] = fmincon(@subfile,[1, 1, 1, 1, 1],[],[],[],[],[0, 0, 0, 0, 0.8],[10 10 10 10 0.8],[], opts);
% You're missing one empty argument for nonlcon ^^
Please, it's best if you define these input arguments before this line of code, it will be much more readable.
VBBV
VBBV 2020 年 11 月 5 日
編集済み: VBBV 2020 年 11 月 5 日
@Vishaka Can you show the error message?
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
sorry, thats right. I inserted the argument for 'nonlcon' as you have suggested. Still getting the same error!
Is this something related to 'Path'?
Thanks
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
This is the error message
Error using optimoptions (line 124)
Empty keys are not allowed in this container.
Error in Main (line 47)
opts = optimoptions(@fmincon,'Algorithm','interior-point');
VBBV
VBBV 2020 年 11 月 5 日
Which version of MATLAB are you using?
VBBV
VBBV 2020 年 11 月 5 日
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
MATLAB R2020a
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
I referred to the link you have sent.
Looks like my problem would be solved. Thanks a lot

サインインしてコメントする。

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2020 年 11 月 5 日
編集済み: Ameer Hamza 2020 年 11 月 5 日

0 投票

Make sure you have optimization toolbox installed
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.9.0.1495850 (R2020b) Update 1
MATLAB License Number: xxxxxx
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19042)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.9 (R2020b)
MATLAB Compiler Version 8.1 (R2020b)
Optimization Toolbox Version 9.0 (R2020b)
Signal Processing Toolbox Version 8.5 (R2020b)

7 件のコメント

Mario Malic
Mario Malic 2020 年 11 月 5 日
It's a good idea to remove your license number I believe.
Ameer Hamza
Ameer Hamza 2020 年 11 月 5 日
I edited away the License number.
Bruno Luong
Bruno Luong 2020 年 11 月 5 日
thanks to both of you
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
Thanks, I am reinstalling with global optimization toolbox
Bruno Luong
Bruno Luong 2020 年 11 月 5 日
編集済み: Bruno Luong 2020 年 11 月 5 日
you only need the optimization toolbox where FMINCON belongs, not the global optimization tollbox.
TMW makes this ridiculuous split. Well not totally ridiculuos since they can make more moneys with the cut.
Vishakha Ranade
Vishakha Ranade 2020 年 11 月 5 日
Thanks a lot. My problem is solved by reinstalling global optimization toolbox. I had already installed the optimization toolbox previously.
Somehow global optimization solved the problem.
Bruno Luong
Bruno Luong 2020 年 11 月 5 日
Odd I don't own global optimization toolbox and it works for me.

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2020 年 11 月 4 日

コメント済み:

2020 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by