LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
workflow_manager.h File Reference

The workflow facade: the port of jar/src/main/java/jline/api/wf/WorkflowManager.java. More...

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <functional>
#include <exception>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "line/api/wf/wf_analyzer.h"
#include "line/api/wf/wf_auto_integration.h"
#include "line/lang/qn/network_struct.h"
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
Include dependency graph for workflow_manager.h:

Go to the source code of this file.

Classes

struct  line::wf::WorkflowPerformanceMetrics
 The four efficiency scores plus the two headline numbers. More...
struct  line::wf::WorkflowAnalysisResult< T >
 Everything analyze_workflow_full returns, i.e. More...
struct  line::wf::PatternComplexityEntry
 Per-pattern-family complexity, one entry of the report's patternComplexity. More...
struct  line::wf::ComplexityReport< T >
 The complexity report, one band per pattern family plus the overall score. More...
struct  line::wf::BenchmarkRow
 One row of the benchmark table. More...
struct  line::wf::WorkflowValidation
 What validate_workflow reports. More...

Namespaces

namespace  line
namespace  line::wf

Enumerations

enum class  line::wf::WfExportFormat { line::wf::Json = 0 , line::wf::Csv , line::wf::Summary }
 The export formats the facade offers. More...

Functions

double line::wf::calculate_sequence_efficiency (const std::vector< std::vector< int > > &sequences)
 avg sequence length capped at 5, the reference's saturation point.
double line::wf::calculate_parallel_efficiency (const std::vector< std::vector< int > > &parallels)
 Efficiency falls linearly past two-way parallelism, floored at 0.1.
double line::wf::calculate_loop_efficiency (const std::vector< int > &loops)
 The reference's placeholder: any loop at all costs half the efficiency.
template<class T>
double line::wf::calculate_branch_efficiency (const std::vector< BranchPattern< T > > &branches)
 The mean NORMALIZED entropy over the branches, i.e.
template<class T>
double line::wf::calculate_complexity_score (std::size_t nodes, std::size_t links, const DetectedPatterns< T > &p)
 The weighted size-plus-pattern score behind the complexity level.
template<class T>
WorkflowPerformanceMetrics line::wf::calculate_performance_metrics (const WorkflowAnalysis< T > &a, const ExtendedSolverRecommendation< T > &r)
 The six metrics of the analysis result.
template<class T>
WorkflowAnalysisResult< T > line::wf::analyze_workflow_full (const qn::NetworkStruct< T > &sn)
 The facade's headline call: analysis, recommendation, insights, metrics.
template<class T>
DetectedPatterns< T > line::wf::get_pattern_analysis (const qn::NetworkStruct< T > &sn)
 The patterns alone.
template<class T>
std::vector< std::string > line::wf::get_workflow_recommendations (const qn::NetworkStruct< T > &sn)
 The recommendation strings alone.
template<class T>
ComplexityReport< T > line::wf::generate_complexity_report (const qn::NetworkStruct< T > &sn)
 The complexity report, with the reference's four bands on the score.
template<class T>
std::vector< std::pair< WfSolver, BenchmarkRow > > line::wf::benchmark_solvers (const std::vector< WfSolver > &solvers, const std::function< Matrix< T >(WfSolver)> &runner)
 Time each solver and aggregate its queue lengths.
std::vector< WfSolverline::wf::default_benchmark_solvers ()
 The reference's default benchmark set.
template<class T>
WorkflowValidation line::wf::validate_workflow (const qn::NetworkStruct< T > &sn)
 The model is well formed and both analyses validate.
template<class T>
std::string line::wf::export_analysis (const WorkflowAnalysisResult< T > &a, WfExportFormat format=WfExportFormat::Summary)
 Render the analysis.
template<class T>
std::string line::wf::quick_analysis (const qn::NetworkStruct< T > &sn)
 The reference's one-call summary.
template<class T>
WfSolver line::wf::get_optimal_solver (const qn::NetworkStruct< T > &sn)
 The chosen solver without the rest of the report.

Detailed Description

The workflow facade: the port of jar/src/main/java/jline/api/wf/WorkflowManager.java.

It composes wf_analyzer.h and wf_auto_integration.h into the things a user asks for – one analysis object, a complexity report, efficiency metrics, a benchmark table and three export formats. There is no new queueing content here; what must be faithful is the arithmetic of the scores and the exact bytes of the exports, since both are what a caller compares across codebases.

THREE DEPARTURES FROM THE JAVA, each named:

  1. factorial is computed in DOUBLE, not int. The Java's int factorial(int) silently overflows at n = 13 and goes NEGATIVE at n = 17, so a workflow with a wide fork would report a negative parallel complexity and a complexity score that DROPS as the model grows. That is a defect, not a convention, so it is not reproduced; the port saturates at infinity in double instead, which keeps the score monotone. Below 13 branches the two agree exactly.
  2. benchmarkSolvers takes a CALLER-SUPPLIED runner. The C++ solvers are free functions over a NetworkStruct rather than a runtime polymorphic family, and api/ does not depend on solvers/ in this tree. Everything the Java method actually does – time the call, record success, aggregate the queue lengths, turn a thrown exception into a failed row – is here; only the construction of the solver is injected.
  3. validateWorkflow reads the node count and the routing off the NetworkStruct rather than the Network object, which is where the port keeps that information.

The Java's calculateLoopEfficiency ignores its own linkMatrix argument and returns the constant 0.5, which its comment admits ("Simplified"). It is ported as written, because changing it would change every metric a caller has recorded; the constant is documented at the function instead.

ARITHMETIC: field, plus what the branch entropy needs.

Definition in file workflow_manager.h.