フィルターのクリア

Dot indexing is not supported for variables of this type on a parfor line with no dot indexing.

14 ビュー (過去 30 日間)
I have been scratching my head for multiple hours on this one. In evaluation.m, I get an error "Dot indexing is not supported for variables of this type" on line 32, which contains "parfor i = 1:x1". There is absolutely zero dot indexing in this line, and the code runs fine when replacing "parfor" with "for". I want to use parfor because this will significantly speed up the runtime of the code (which takes hours or days).
What is going on, and how can I fix this?
function [Y, g, avgFullTravelTime, scoreFactor]=evaluation(P, numInputs)
% P = population
[x1, y1]=size(P);
H=zeros(1,x1);
Vissim = actxserver('Vissim.Vissim');
path = 'C:\Users\Public\Documents\PTV Vision\PTV Vissim 2022\Pitt Campus\Calibration Network with slopes';
filename = fullfile(path, 'Pitt_Campus_Model_1-6-23(new).inpx');
Vissim.LoadNet(filename, false);
expectedTime = [346,393,479,451,462,494,260,388,145,297,422,311];
measureRange = [48, 49, 50, 52, 54, 57, 59, 61, 65, 66, 67, 68, 69];
% NumberRoute [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
routes = length(expectedTime);
segments = 21;
score = zeros(x1);
scoreFactor = zeros(x1, routes);
avgFullTravelTime = zeros(x1, routes);
g = zeros(x1, routes);
totalTravelTime = zeros(x1, segments);
vehsPerTimeInt = zeros(x1, segments, 3);
avgTTPerTimeInt = zeros(x1, segments, 3);
avgTravelTime = zeros(x1, segments);
for w = 1:segments
Veh_TT_measurement(w) = Vissim.Net.VehicleTravelTimeMeasurements.ItemByKey(w+47);
end
parfor i = 1:x1
tic
vpti1 = zeros(segments, 3);
attpti1 = zeros(segments, 3);
ttt1 = zeros(segments);
tv1 = zeros(segments);
att1 = zeros(segments);
aftt1 = zeros(routes);
g1 = zeros(routes);
sf1 = zeros(routes);
% rest of code
end
  2 件のコメント
Matt J
Matt J 2023 年 6 月 13 日
編集済み: Matt J 2023 年 6 月 13 日
I get an error "Dot indexing is not supported for variables of this type" on line 32
We need to see the error message copy/pasted. Also, some inputs to the code that we can reproduce the error with would probably help.
Noah
Noah 2023 年 6 月 14 日
I have done what others suggested and put the body of the code in a new function. Now, I get the (copy-pasted) error:
Error using evaluationLoopBody (line 23)
Dot indexing is not supported for variables of this type.
on the line:
Vissim.Net.VehicleInputs.ItemByKey(vin).set('AttValue', 'Volume(1)', amount(vin));
The inputs for the main evaluation function are numInputs, which is currently set to 82, and P, a 48x984 matrix of doubles that are all either 0 or 1.

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

回答 (2 件)

Raymond Norris
Raymond Norris 2023 年 6 月 14 日
My guess is that it has to do with your ActiveX Server, specifically if Veh_TT_measurement is used in your parfor. See if this will help
  4 件のコメント
Noah
Noah 2023 年 6 月 16 日
This answer is leading me in the right direction. I might ask more questions later, but for now I seem good.

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


Edric Ellis
Edric Ellis 2023 年 6 月 14 日
移動済み: Image Analyst 2023 年 6 月 14 日
Unfortunately, error messages from anywhere within a parfor loop are reported as occurring on the line where the loop starts. This is a current limitation of the way parfor works. As a workaround, if you put the entire body of the loop into a separate function, you'll get a more sensible error message.
Almost certainly as @Raymond Norris suggests it is to do with the ActiveX object - if this cannot be saved and loaded correctly, it may show up having the value [] inside the parfor loop, and then you'll end up with the error you posted when you try to apply a dot-reference to it.
  3 件のコメント
Raymond Norris
Raymond Norris 2023 年 6 月 15 日
parfor won't display the error dialog box. I expect this would hang the MATLAB client.
Edric Ellis
Edric Ellis 2023 年 6 月 16 日
Yeah, better to do
assert(~isempty(Vissim), 'Vissim is empty!')

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

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by