{"id":25649631,"url":"https://github.com/pieterderycke/jace","last_synced_at":"2025-05-15T16:04:47.722Z","repository":{"id":5070112,"uuid":"6232011","full_name":"pieterderycke/Jace","owner":"pieterderycke","description":"Jace.NET is a calculation engine for the .NET platform.","archived":false,"fork":false,"pushed_at":"2023-01-05T10:02:12.000Z","size":5923,"stargazers_count":441,"open_issues_count":38,"forks_count":94,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-07T21:13:10.178Z","etag":null,"topics":["c-sharp","calculation-engine","formula","interpreter","jace","mathematical-formulas"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jeremylong/DependencyCheck","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pieterderycke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-15T18:32:00.000Z","updated_at":"2025-04-01T06:05:33.000Z","dependencies_parsed_at":"2023-01-13T13:21:05.544Z","dependency_job_id":null,"html_url":"https://github.com/pieterderycke/Jace","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pieterderycke%2FJace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pieterderycke%2FJace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pieterderycke%2FJace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pieterderycke%2FJace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pieterderycke","download_url":"https://codeload.github.com/pieterderycke/Jace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730069,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","calculation-engine","formula","interpreter","jace","mathematical-formulas"],"created_at":"2025-02-23T14:22:58.210Z","updated_at":"2025-04-07T21:13:15.439Z","avatar_url":"https://github.com/pieterderycke.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jace.NET\nJace.NET is a high performance calculation engine for the .NET platform. It stands for \"Just Another Calculation Engine\".\n\n## Build Status\n* [![Build status](https://ci.appveyor.com/api/projects/status/0qas60k4tlhi2b1d/branch/master?svg=true)](https://ci.appveyor.com/project/pieterderycke/jace/branch/master) (master)\n* [![Build status](https://ci.appveyor.com/api/projects/status/0qas60k4tlhi2b1d/branch/dev?svg=true)](https://ci.appveyor.com/project/pieterderycke/jace/branch/dev) (dev)\n\n## What does it do?\nJace.NET can interprete and execute strings containing mathematical formulas. These formulas can rely on variables. If variables are used, values can be provided for these variables at execution time of the mathematical formula.\n\nJace can execute formulas in two modes: in interpreted mode and in a dynamic compilation mode. If dynamic compilation mode is used, Jace will create a dynamic method at runtime and will generate the necessary MSIL opcodes for native execution of the formula. If a formula is re-executed with other variables, Jace will take the dynamically generated method from its cache. It is recommended to use Jace in dynamic compilation mode.\n\n## Wiki\nFor detailed information how to use Jace.NET, please consult the [wiki](https://github.com/pieterderycke/Jace/wiki)\n\n## Architecture\nJace.NET follows a design similar to most of the modern compilers. Interpretation and execution is done in a number of phases:\n\n### Tokenizing\nDuring the tokenizing phase, the string is converted into the different kind of tokens: variables, operators and constants.\n### Abstract Syntax Tree Creation\nDuring the abstract syntax tree creation phase, the tokenized input is converted into a hierarchical tree representing the mathematically formula. This tree unambiguously stores the mathematical calculations that must be executed.\n### Optimization\nDuring the optimization phase, the abstract syntax tree is optimized for executing.\n### Interpreted Execution/Dynamic Compilation\nIn this phase the abstract syntax tree is executed in either interpreted mode or in dynamic compilation mode.\n\n## Examples\nJace.NET can be used in a couple of ways:\n\nTo directly execute a given mathematical formula using the provided variables:\n```csharp\nDictionary\u003cstring, double\u003e variables = new Dictionary\u003cstring, double\u003e();\nvariables.Add(\"var1\", 2.5);\nvariables.Add(\"var2\", 3.4);\n\nCalculationEngine engine = new CalculationEngine();\ndouble result = engine.Calculate(\"var1*var2\", variables);\n```\n\nTo build a .NET Func accepting a dictionary as input containing the values for each variable:\n```csharp\nCalculationEngine engine = new CalculationEngine();\nFunc\u003cDictionary\u003cstring, double\u003e, double\u003e formula = engine.Build(\"var1+2/(3*otherVariable)\");\n\nDictionary\u003cstring, double\u003e variables = new Dictionary\u003cstring, double\u003e();\nvariables.Add(\"var1\", 2);\nvariables.Add(\"otherVariable\", 4.2);\n\t\ndouble result = formula(variables);\n```\n\nTo build a typed .NET Func:\n```csharp\nCalculationEngine engine = new CalculationEngine();\nFunc\u003cint, double, double\u003e formula = (Func\u003cint, double, double\u003e)engine.Formula(\"var1+2/(3*otherVariable)\")\n\t.Parameter(\"var1\", DataType.Integer)\n    .Parameter(\"otherVariable\", DataType.FloatingPoint)\n    .Result(DataType.FloatingPoint)\n    .Build();\n\t\ndouble result = formula(2, 4.2);\n```\n\nFunctions can be used inside the mathemical formulas. Jace.NET currently offers four functions accepting one argument (sin, cos, loge and log10) and one function accepting two arguments (logn).\n\n```csharp\nDictionary\u003cstring, double\u003e variables = new Dictionary\u003cstring, double\u003e();\nvariables.Add(\"var1\", 2.5);\nvariables.Add(\"var2\", 3.4);\n\nCalculationEngine engine = new CalculationEngine();\ndouble result = engine.Calculate(\"logn(var1,var2)+4\", variables);\n```\n\n## Performance\nBelow you can find the results of Jace.NET benchmark that show its high performance calculation engine. Tests were done on an Intel i7 2640M laptop.\n1000 random formulas were generated, each containing 3 variables and a number of constants (a mix of integers and floating point numbers). Each random generated formula was executed 10 000 times. So in total 10 000 000 calculations are done during the benchmark. You can find the benchmark application in \"Jace.Benchmark\" if you want to run it on your system.\n\n* Interpreted Mode : 00:00:06.7860119\n* Dynamic Compilation Mode: 00:00:02.5584045\n\n## Compatibility\nIf you are using Jace.NET inside a Unity project using IL2CPP you must use Jace.NET in interpreted mode due to limitations of IL2CPP with dynamic code generation.\n\n## More Information\nFor more information, you can read the following articles:\n* http://pieterderycke.wordpress.com/2012/11/04/jace-net-just-another-calculation-engine-for-net/\n* http://www.codeproject.com/Articles/682589/Jace-NET-Just-another-calculation-engine-for-NET","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpieterderycke%2Fjace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpieterderycke%2Fjace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpieterderycke%2Fjace/lists"}