2020-05-24 01:57:27 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.ML;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Game1.Sources.ML_Joel
|
|
|
|
|
{
|
|
|
|
|
static class Engine
|
|
|
|
|
{
|
|
|
|
|
private static MLContext mlContext = new MLContext(seed: 1);
|
2020-05-24 21:00:54 +02:00
|
|
|
|
private static PredictionEngine<Input, Output> PredictionEngine;
|
|
|
|
|
private static PredictionEngine<InputArea, OutputArea> PredictionEngineArea;
|
|
|
|
|
|
2020-05-24 01:57:27 +02:00
|
|
|
|
|
|
|
|
|
public static void CreateModel()
|
|
|
|
|
{
|
|
|
|
|
Model.CreateModel();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-24 21:00:54 +02:00
|
|
|
|
public static void CreateModelArea()
|
|
|
|
|
{
|
|
|
|
|
Model.CreateModelArea();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-24 01:57:27 +02:00
|
|
|
|
public static void init()
|
|
|
|
|
{
|
2020-05-24 21:00:54 +02:00
|
|
|
|
PredictionEngine = Model.CreateEngine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void initArea()
|
|
|
|
|
{
|
|
|
|
|
PredictionEngineArea = Model.CreateEngineArea();
|
2020-05-24 01:57:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-24 22:21:49 +02:00
|
|
|
|
public static float PredictProductionwithRainfall(SoilProperties soilProperties, DayNightCycle Time)
|
2020-05-24 01:57:27 +02:00
|
|
|
|
{
|
2020-05-24 21:00:54 +02:00
|
|
|
|
InputArea modelInput = new InputArea
|
2020-05-24 01:57:27 +02:00
|
|
|
|
{
|
2020-05-24 22:21:49 +02:00
|
|
|
|
Season = Time.getTimeOfYear(),
|
|
|
|
|
Area = soilProperties.Area,
|
|
|
|
|
Rainfall = soilProperties.Humidity,
|
2020-05-24 01:57:27 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-05-25 11:07:58 +02:00
|
|
|
|
OutputArea modelOutput = new OutputArea();
|
|
|
|
|
PredictionEngineArea.Predict(modelInput, ref modelOutput);
|
|
|
|
|
return modelOutput.Score;
|
2020-05-24 01:57:27 +02:00
|
|
|
|
}
|
2020-05-25 10:59:17 +02:00
|
|
|
|
|
2020-05-24 01:57:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|