Download Icon
Transcript
end
consume_tokens.m
Note that the blue highlight is the original source code of the GpenSIM consume_tokens.m
function [delta_X,index_OP,inherited_color_set,inherited_costs] = ...
consume_tokens (transition, selected_tokID)
global PN;
Ps = PN.No_of_places;
A = PN.incidence_matrix;
%token removals from input place
input_weigths = A(transition,1:Ps); %extracting the weight of input arcs
% disp('input_weigths');
% disp(input_weigths)
inherited_color_set = {};
inherited_costs = 0;
% Move input tokens into Virtual places as "virtual tokens"
PN.X = PN.X - input_weigths; % take tokens from input places ...
PN.VX = PN.VX + input_weigths; % and push into Virtual places
PN.global_transitions(transition).absorbed_tokens = input_weigths;
for i = 1:Ps,
tokens_to_be_consumed = input_weigths(i);
% disp('tokens_to_be_consumed');disp(tokens_to_be_consumed)
if (tokens_to_be_consumed),
% %%%%%%% NGT %%%%%%%
% display the following
% transiton = transiton,
% place = i,
% number of tokens = tokens_to_be_consumed
% time = PN.current_time
% %%%%%%% NGT %%%%%%%
[inherited_color_from_pi, inherited_costs_pi, selected_tokID] = ...
consume_token_in_place_i ...
(i, tokens_to_be_consumed, selected_tokID);
% inherit colors and costs from different places
inherited_color_set = union(inherited_color_set, ...
inherited_color_from_pi);
inherited_costs = inherited_costs + inherited_costs_pi;
%disp('inherited_costs');disp(inherited_costs);
%NGT infoplc.m called here
infoplc(i,transition,tokens_to_be_consumed);
end;
end;
C.2 gpensim codes for the R-T system models
i.
Source code for production line
151