NPKTools.Optimizer.Preset 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NPKTools.Optimizer.Preset --version 1.1.0                
NuGet\Install-Package NPKTools.Optimizer.Preset -Version 1.1.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="NPKTools.Optimizer.Preset" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NPKTools.Optimizer.Preset --version 1.1.0                
#r "nuget: NPKTools.Optimizer.Preset, 1.1.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.
// Install NPKTools.Optimizer.Preset as a Cake Addin
#addin nuget:?package=NPKTools.Optimizer.Preset&version=1.1.0

// Install NPKTools.Optimizer.Preset as a Cake Tool
#tool nuget:?package=NPKTools.Optimizer.Preset&version=1.1.0                

NPKTools.Optimizer.Preset

  • NPKTools.Optimizer.Preset is an preconfigured version of the NPKTools.Optimizer. It includes:
  • 17 basic types of macronutrient fertilizers combined into 18 different sets to optimize the selection process.
  • 17 types of micronutrient fertilizers grouped into four main sets: basic, sulfate, nitrate, and chelated.
  • During the selection of macronutrient fertilizers, the service conducts two searches: in the first, sulfur is accounted for as specified, while the second search excludes sulfur coefficients to expand the possible options.

Developers

This tool was developed by Anatoliy Yermakov.

Special thanks to Artem Frolov for his invaluable assistance and guidance in the development of this project.

Installation and Configuration

This section guides you through setting up and configuring the necessary components for the project using Dependency Injection (DI).

Direct Instantiation

To manually instantiate the components without using DI, use the following example:

// Creating instances manually without DI
        IOptimizationProblemSolver solver = new GoogleOrToolsOptimizationSolver();
        IOptimizationProblemMapper mapper = new OptimizationProblemMapper();
        IFertilizerOptimizer optimizer = new FertilizerOptimizationAdapter(solver, mapper);
        IFertilizerBundleRepository bundles = new FertilizerBundleRepository();        
        IFertilizerOptimizationService = new FertilizerOptimizationService(optimizer, bundles);

Using Dependency Injection For integrating these components into a project that supports Dependency Injection, such as an ASP.NET Core application, configure your services in the Startup.cs or a similar configuration file as follows:

public void ConfigureServices(IServiceCollection services)
{
    // Registering services in the DI container
    services.AddSingleton<IOptimizationProblemSolver, GoogleOrToolsOptimizationSolver>();
    services.AddSingleton<IOptimizationProblemMapper, OptimizationProblemMapper>();
    services.AddSingleton<IFertilizerOptimizer, FertilizerOptimizationAdapter>();
    services.AddSingleton<IFertilizerBundleRepository, FertilizerBundleRepository>();
    services.AddSingleton<IFertilizerOptimizationService, FertilizerOptimizationService>();
}

Example usage

// Creating instances manually without DI
IOptimizationProblemSolver solver = new GoogleOrToolsOptimizationSolver();
IOptimizationProblemMapper mapper = new OptimizationProblemMapper();
IFertilizerOptimizer optimizer = new FertilizerOptimizationAdapter(solver, mapper);
IFertilizerBundleRepository bundles = new FertilizerBundleRepository();
IFertilizerOptimizationService fertilizerOptimizationService = new FertilizerOptimizationService(optimizer, bundles);

// Define your PPM target for optimization
PpmTarget target = new PpmTargetBuilder()
    .AddN(150)
    .AddP(50)
    .AddK(200)
    .AddMg(60)
    .AddCa(60)
    .AddS(80)
    .Build();

// Set the options for matching the macro elements precisely
SolutionFinderSettings settings = new SolutionFinderSettingsBuilder()
    .AddN(1)
    .AddP(1)
    .AddK(1)
    .AddCa(1)
    .AddMg(1)
    .AddS(1)
    .AddCl(1)
    .Build();

// Finding macro solutions based on the specified target
Solutions macroSolutions = fertilizerOptimizationService.FindMacroSolutions(target);

// Finding micro solutions with a different target
PpmTarget microTarget = new PpmTargetBuilder()
    .AddFe(2)
    .AddCu(0.05)
    .AddMn(0.55)
    .AddZn(0.33)
    .AddB(0.28)
    .AddMo(0.05)
    .AddSi(0.01)
    .AddSe(0.01)
    .Build();

Solutions microSolutions = fertilizerOptimizationService.FindMicroSolutions(microTarget);

// Combine both macro and micro nutrient optimizations
(Solutions Macro, Solutions Micro) results = fertilizerOptimizationService.FindSolutions(new PpmTargetBuilder()
    .AddN(150)
    .AddP(50)
    .AddK(200)
    .AddMg(60)
    .AddCa(100)
    .AddS(100)
    .AddFe(2)
    .AddCu(0.05)
    .AddMn(0.55)
    .AddZn(0.33)
    .AddB(0.28)
    .AddMo(0.05)
    .AddCl(0.01)
    .AddSi(0.01)
    .AddSe(0.01)
    .Build());

// You can now access results.Macro and results.Micro for specific optimizations

License:

This project is licensed under the MIT License.

Dependencies

NPKTools.Optimizer.Preset.Tests

Contact Information:

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.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
1.1.3 108 5/14/2024
1.1.2 114 5/14/2024
1.1.1 105 5/3/2024
1.1.0 82 5/3/2024
1.0.0 93 5/2/2024

Combined FertilizerOptimizationModel and Fertilizer to Fertilizer
           FertilizerCollectionBuilder add Name, Formula and ConcentrationType