ApprenticeFoundryMentorModeler 24.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ApprenticeFoundryMentorModeler --version 24.0.0
                    
NuGet\Install-Package ApprenticeFoundryMentorModeler -Version 24.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ApprenticeFoundryMentorModeler" Version="24.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApprenticeFoundryMentorModeler" Version="24.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ApprenticeFoundryMentorModeler" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ApprenticeFoundryMentorModeler --version 24.0.0
                    
#r "nuget: ApprenticeFoundryMentorModeler, 24.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ApprenticeFoundryMentorModeler@24.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ApprenticeFoundryMentorModeler&version=24.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ApprenticeFoundryMentorModeler&version=24.0.0
                    
Install as a Cake Tool

Foundry Mentor Modeler

NuGet License .NET

Advanced knowledge modeling framework with intelligent unit system for engineering applications

๐Ÿš€ What is Foundry Mentor Modeler?

Foundry Mentor Modeler is a powerful .NET library that provides intelligent parameter modeling, formula evaluation, and unit-aware calculations for engineering and scientific applications. It enables developers to create sophisticated models with automatic unit handling, dependency tracking, and dynamic formula evaluation.

โœจ Key Features

๐Ÿงฎ Intelligent Parameter System

  • Dynamic Formula Evaluation: Create parameters with complex formulas that automatically resolve dependencies
  • Unit-Aware Calculations: Built-in support for 15+ unit families with automatic type safety
  • Dependency Tracking: Automatic detection and management of parameter relationships
  • Circular Reference Detection: Built-in protection against infinite evaluation loops

๐Ÿ“ Advanced Unit System Integration

  • 39+ Unit Families: Length, Distance, Angle, Bearing, Time, Duration, Mass, Force, Temperature, Voltage, and more
  • Dual Family Pattern: Scale-optimized families (Length/Distance, Angle/Bearing, Time/Duration)
  • Mixed Unit Support: Imperial, Metric, and specialized engineering units across 6 unit systems
  • Type-Safe Operations: Prevents invalid unit conversions (e.g., adding angles to lengths)
  • Dynamic Unit Detection: Automatically creates correct MeasuredValue types

๐Ÿ”— Knowledge Modeling

  • Hierarchical Instances: Create complex models with parent-child relationships
  • Component Systems: Build reusable components with subcomponent relationships
  • Reference Resolution: Sophisticated reference system for accessing model data
  • Persistence Support: Save and load model states

๐Ÿ“ฆ Installation

NuGet Package Manager

Install-Package FoundryMentorModeler

.NET CLI

dotnet add package FoundryMentorModeler

PackageReference

<PackageReference Include="FoundryMentorModeler" Version="1.0.0" />

๐Ÿƒโ€โ™‚๏ธ Quick Start

Basic Parameter Creation

using FoundryMentorModeler.Model;

// Create a model instance
var robot = new KnInstance("Robot");

// Add parameters with units
var speed = robot.Parameter("maxSpeed", 2.5, "m/s");
var weight = robot.Parameter("weight", 15.0, "kg"); 
var angle = robot.Parameter("heading", 45.0, "deg");

Formula-Based Parameters

// Create calculated parameters
var distance = robot.Parameter("distance", 0.0, "m");
var time = robot.Parameter("time", 0.0, "s");

// Add formula that references other parameters
var avgSpeed = robot.Parameter("avgSpeed", 0.0, "m/s");
avgSpeed.ApplyFormula("distance / time", UnitSystem.Default);

// Set values and watch automatic calculation
distance.SetValue(100.0); // 100 meters
time.SetValue(40.0);      // 40 seconds
// avgSpeed automatically becomes 2.5 m/s

Dual Family Pattern Usage

// Use appropriate family for scale context
var robot = new KnInstance("AutonomousRobot");

// Engineering measurements (Length family - meter base)
var sensorRange = robot.Parameter("sensorRange", 5.0, "m");      // โ†’ Length family
var wheelDiameter = robot.Parameter("wheelDiameter", 15.0, "cm"); // โ†’ Length family

// Navigation measurements (Distance family - kilometer base)  
robot.ApplyFormula("missionDistance", "ASDISTANCE(25, 'km')");    // โ†’ Distance family
robot.ApplyFormula("waypointGap", "ASDISTANCE(500, 'm')");       // โ†’ Distance family

// Same input units, different optimized scales:
Console.WriteLine(sensorRange.BaseValue());    // 5.0 (meters - engineering scale)
Console.WriteLine(missionDistance.BaseValue()); // 25.0 (kilometers - geographic scale)

Hierarchical Models

// Create a complex system
var droneSystem = new KnInstance("DroneSystem");

// Add subsystems
var propulsion = droneSystem.AddMember(new KnInstance("Propulsion"));
var navigation = droneSystem.AddMember(new KnInstance("Navigation"));

// Add parameters to subsystems
propulsion.Parameter("thrust", 50.0, "N");
navigation.Parameter("altitude", 100.0, "m");
navigation.Parameter("gpsAccuracy", 2.0, "m");

// Compute all values recursively
droneSystem.ComputeAll<KnInstance>(deep: true);

๐Ÿ”ง Advanced Usage

Custom Formulas

var circle = new KnInstance("Circle");
circle.Parameter("radius", 5.0, "m");
circle.Parameter("area", 0.0, "mยฒ");

// Complex formula with built-in functions
var area = circle.FindParameter("area");
area.ApplyFormula("3.14159 * radius * radius", UnitSystem.Default);

Unit System Integration

// Works with FoundryRulesAndUnits
var unitSystem = new UnitSystem();
unitSystem.Apply(UnitSystemType.SI);

// Parameters automatically use proper unit system
var force = new KnParameter("force", 9.8, "N");
var acceleration = new KnParameter("acceleration", 9.8, "m/sยฒ");

Dependency Management

var circuit = new KnInstance("Circuit");
var voltage = circuit.Parameter("voltage", 12.0, "V");
var current = circuit.Parameter("current", 2.0, "A");
var power = circuit.Parameter("power", 0.0, "W");

power.ApplyFormula("voltage * current", UnitSystem.Default);

// Changing voltage automatically updates power
voltage.SetValue(24.0); // Power becomes 48W automatically

๐Ÿ” Architecture

Core Components

  • KnInstance: Base knowledge instance with hierarchical capabilities
  • KnParameter: Unit-aware parameter with formula evaluation
  • Operator: Expression evaluation system with unit support
  • OPResult: Type-safe result container with status tracking

Unit System Integration

Foundry Mentor Modeler integrates seamlessly with FoundryRulesAndUnits to provide:

  • Automatic unit family detection
  • Type-safe MeasuredValue creation
  • Cross-unit conversion prevention
  • Engineering-grade precision

๐Ÿ“š Documentation

Comprehensive Guides

API Reference

๐ŸŽฏ Use Cases

Engineering Applications

  • Robotics: Model robot parameters with unit-aware calculations
  • Mechanical Design: Create assemblies with dimensional relationships
  • Control Systems: Model feedback loops with parameter dependencies

Scientific Computing

  • Physics Simulations: Unit-safe calculations across measurement types
  • Data Analysis: Parameter relationships with automatic computation
  • Experimental Design: Model experimental setups with validation

Industrial Systems

  • Process Control: Model industrial processes with interconnected parameters
  • Quality Assurance: Create measurement systems with tolerance checking
  • System Integration: Build complex multi-component systems

๐Ÿ› ๏ธ Requirements

  • .NET 8.0 or later
  • FoundryRulesAndUnits (automatically included)
  • FoundryCore (automatically included)

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

git clone https://github.com/SteveStrong/FoundryMentorModeler.git
cd FoundryMentorModeler
dotnet restore
dotnet build
dotnet test

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†• Recent Updates (October 2025)

๐Ÿ—๏ธ Dual Family Pattern - Complete Implementation

  • โœ… Distance Family Fix: Resolved critical bug where Distance family couldn't accept 'm' units
  • โœ… Cross-System Support: All 6 unit systems (SI, MKS, CGS, FPS, IPS, mmNs) now support dual families
  • โœ… Scale-Optimized Architecture: Length/Distance, Angle/Bearing, Time/Duration dual families complete
  • โœ… Parser Integration: Made Distance parser-accessible across all unit system specifications

๐Ÿ”ง Unit System Enhancements

  • โœ… Comprehensive Validation: All Distance tests passing (7/7) with robust cross-system validation
  • โœ… Base Unit Optimization: Engineering-scale (meters) vs Geographic-scale (kilometers) mathematics
  • โœ… AS Function Support: ASDISTANCE(5, 'm'), ASBEARING(45, 'deg') for explicit family assignment
  • โœ… Backward Compatibility: Existing code unchanged, new dual family features available

๐Ÿ“‹ Implementation Scope

  • Distance Family: Now accepts all Length units (m, cm, ft, in, km, mi, etc.) in all 6 systems
  • Dual Family Benefits: Context-appropriate base units (Lengthโ†’meters, Distanceโ†’kilometers)
  • Testing Framework: Comprehensive validation ensuring consistent behavior across all specifications

๐Ÿ†• Recent Updates (September 2025)

๐Ÿš€ Major Performance Optimization - 5-10x Faster Expression Evaluation

  • โœ… TokenID-Based Dispatch: Replaced string comparisons with enum switching for 5-10x performance gain
  • โœ… Unified Function Registry: Single source of truth for 50+ functions (Math, String, Date, Engineering)
  • โœ… Token-Based Architecture: All operators now use consistent Operator(Token) constructor pattern
  • โœ… Pure Evaluation: Clean separation between parsing and evaluation phases

๐Ÿ—๏ธ Architectural Transformation

  • โœ… FunctionOperator Cleanup: Eliminated hundreds of lines of legacy code, removed "hard-to-read" patterns
  • โœ… IUnitSystem Dependency Removal: Pure evaluation operators using static methods
  • โœ… Parser-Evaluator Separation: Dedicated FunctionParser for clean architectural boundaries
  • โœ… Memory Optimization: Eliminated Name.ToUpper() calls and string allocations in hot paths

๐Ÿ“Š Proven Performance Improvements

  • BinaryOperator: 8-10x faster arithmetic dispatch (+, -, *, /)
  • CompareOperator: 6-8x faster comparison operations (==, >, <, etc.)
  • LogicalBinaryOperator: 5-7x faster logical operations (AND, OR)
  • FunctionOperator: 3-5x faster function lookup with unified registry

๐Ÿ”ง Enhanced Unit System

  • โœ… Dimensionless Default Strategy: Safe handling of unknown units
  • โœ… 15+ Unit Families: Complete engineering unit coverage
  • โœ… Cross-Family Protection: Prevents invalid unit conversions
  • โœ… API Consistency: Full integration with FoundryRulesAndUnits

๐Ÿ“š Comprehensive Documentation

๐Ÿ“ž Support

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
24.1.0 159 10/22/2025
24.0.0 169 10/15/2025
23.4.0 168 9/25/2025
23.1.0 163 9/24/2025
23.0.0 171 9/24/2025
21.3.0 150 9/13/2025
21.1.0 153 9/13/2025
21.0.0 171 9/11/2025
20.3.0 167 8/11/2025
20.2.0 168 8/10/2025
20.0.0 139 8/9/2025
19.0.0 145 7/28/2025
18.4.5 252 4/19/2025
18.4.4 238 4/17/2025
18.4.2 256 4/14/2025
18.4.1 223 4/14/2025
18.4.0 255 4/14/2025
18.3.0 139 4/4/2025
18.2.0 178 3/16/2025
18.0.0 171 2/23/2025
17.2.2 157 1/28/2025
17.1.2 137 1/28/2025
16.6.0 159 12/11/2024
16.5.0 132 12/8/2024
16.4.0 140 12/1/2024
16.3.0 123 11/26/2024
16.2.0 141 11/21/2024
15.10.3 143 10/27/2024
15.10.2 145 10/27/2024
15.10.1 162 10/11/2024
15.10.0 183 10/10/2024
15.9.0 134 10/10/2024
15.7.0 155 10/5/2024
15.5.0 153 9/13/2024
15.2.1 175 9/11/2024
15.2.0 169 9/11/2024
14.7.0 156 8/30/2024
14.6.0 167 8/28/2024
14.5.0 183 8/25/2024
14.0.2 175 8/23/2024
14.0.1 160 8/21/2024
14.0.0 158 8/21/2024
13.3.0 173 8/20/2024
2.3.0 162 8/20/2024
2.2.0 135 7/25/2024
1.1.1 157 6/2/2024