LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
wf_loop.m
1%% Loop Workflow Example
2% A workflow with a repeated activity.
3%
4% Workflow: A -> [B x 3] -> C
5% Activity B is executed 3 times.
6%
7% Copyright (c) 2012-2026, Imperial College London
8% All rights reserved.
9
10clear;
11lineStart;
12
13%% Define the workflow
14wf = Workflow('LoopWorkflow');
15
16% Add activities
17A = wf.addActivity('A', Exp.fitMean(1.0));
18B = wf.addActivity('B', Exp.fitMean(2.0));
19C = wf.addActivity('C', Exp.fitMean(0.5));
20
21% Define loop: A runs once, B runs 3 times, C runs once
22wf.addPrecedence(Workflow.Loop(A, {B, C}, 3));
23
24%% Convert to phase-type distribution
25ph = wf.toPH();
26
27%% Display results
28fprintf('Loop Workflow: A -> [B x 3] -> C\n');
29fprintf('Activity means: A=1.0, B=2.0, C=0.5\n');
30fprintf('Expected total mean: 1.0 + 3*2.0 + 0.5 = %.2f\n', 1.0 + 3*2.0 + 0.5);
31fprintf('Computed PH mean: %.4f\n', ph.getMean());
32fprintf('Number of phases: %d\n', size(ph.getSubgenerator(), 1));