1function initFromMarginal(self, n, options) % n(i,r) : number of jobs of class r in node or station i (autodetected)
2% INITFROMMARGINAL(N, OPTIONS) % N(I,R) : NUMBER OF JOBS OF CLASS R IN NODE OR STATION I
4%global GlobalConstants.CoarseTol
6if nargin<3 %~exist(
'options',
'var')
7 options = Solver.defaultOptions;
15if self.getNumberOfStations() < self.getNumberOfNodes()
16 if size(n,1)==self.getNumberOfStations()
17 nnodes = zeros(sn.nnodes,size(n,2));
18 for ist=1:sn.nstations
19 ind = sn.stationToNode(ist);
20 nnodes(ind,:) = n(ist,:);
23 elseif size(n,1)==self.getNumberOfNodes()
26 line_error(mfilename,
'The supplied matrix of marginal states does not have the correct number of rows. One either one per station or one per node.');
30[isvalidn] = State.isValid(sn, n, [], options);
32 % line_error(mfilename,
'The specified state does not have the correct number of jobs.');
33 line_warning(mfilename,
'Initial state not contained in the state space. Trying to recover.\n');
35 [isvalidn] = State.isValid(sn, n, [], options);
37 line_error(mfilename,
'Cannot recover - stopping.');
42 switch sn.nodetype(ind)
46 if max(abs(n(ind,:) - round(n(ind,:)))) < GlobalConstants.CoarseTol
47 state_i = State.fromMarginal(sn,ind,round(n(ind,:)));
48 else % the state argument
is purposedly given fractional, e.g.
for Fluid solver initialization
53 self.nodes{ind}.setStateSpace(state_i);
54 self.nodes{ind}.setStatePrior(1);
55 self.nodes{ind}.setState(state_i);
56 elseif size(state_i,1)>1
57 prior_state_i = zeros(1,size(state_i,1)); prior_state_i(1) = 1;
58 self.nodes{ind}.setStateSpace(state_i);
59 self.nodes{ind}.setStatePrior(prior_state_i);
60 self.nodes{ind}.setState(state_i(1,:));
62 self.nodes{ind}.setStateSpace([]);
63 self.nodes{ind}.setStatePrior([]);
64 self.nodes{ind}.setState([]);
66 if isempty(self.nodes{ind}.getState)
67 line_error(mfilename,sprintf('Invalid state assignment for station %d.',ind));