LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
wf_branch.m
1%% Probabilistic Branching Workflow Example (OR-fork/join)
2% A workflow with probabilistic choice between branches.
3%
4% Workflow:
5% +-> B (60%) --+
6% A --| |--> D
7% +-> C (40%) --+
8%
9% Copyright (c) 2012-2026, Imperial College London
10% All rights reserved.
11
12clear;
13lineStart;
14
15%% Define the workflow
16wf = Workflow('BranchingWorkflow');
17
18% Add activities
19A = wf.addActivity('A', Exp.fitMean(1.0));
20B = wf.addActivity('B', Exp.fitMean(2.0));
21C = wf.addActivity('C', Exp.fitMean(5.0));
22D = wf.addActivity('D', Exp.fitMean(0.5));
23
24% Define precedences with probabilities
25wf.addPrecedence(Workflow.OrFork(A, {B, C}, [0.6, 0.4]));
26wf.addPrecedence(Workflow.OrJoin({B, C}, D));
27
28%% Convert to phase-type distribution
29ph = wf.toPH();
30
31%% Display results
32fprintf('Branching Workflow: A -> [B(60%%) | C(40%%)] -> D\n');
33fprintf('Activity means: A=1.0, B=2.0, C=5.0, D=0.5\n');
34expected_branch = 0.6 * 2.0 + 0.4 * 5.0;
35fprintf('Expected branch mean: 0.6*2.0 + 0.4*5.0 = %.2f\n', expected_branch);
36fprintf('Expected total mean: %.2f\n', 1.0 + expected_branch + 0.5);
37fprintf('Computed PH mean: %.4f\n', ph.getMean());
38fprintf('Number of phases: %d\n', size(ph.getSubgenerator(), 1));