public Controller(string _pyPath, string _pyScriptsPath) { this.pythonPath = _pyPath; this.pythonScriptsPath = _pyScriptsPath; P = new Persistence(); GAP = new GAPclass(); pyRunner = new PythonRunner(pythonPath, 20000); }
// Reads an instance from the db public void readGAPinstance(string dbpath, GAPclass G) { int i, j; List <int> lstCap; List <double> lstCosts; try { using (var ctx = new SQLiteDatabaseContext(dbpath)) { lstCap = ctx.Database.SqlQuery <int>("SELECT cap from capacita").ToList(); G.m = lstCap.Count(); G.cap = new int[G.m]; for (i = 0; i < G.m; i++) { G.cap[i] = lstCap[i]; } lstCosts = ctx.Database.SqlQuery <double>("SELECT cost from costi").ToList(); G.n = lstCosts.Count / G.m; G.c = new double[G.m, G.n]; G.req = new int[G.n]; G.sol = new int[G.n]; G.solbest = new int[G.n]; G.zub = Double.MaxValue; G.zlb = Double.MinValue; for (i = 0; i < G.m; i++) { for (j = 0; j < G.n; j++) { G.c[i, j] = lstCosts[i * G.n + j]; } } for (j = 0; j < G.n; j++) { G.req[j] = -1; // placeholder } } } catch (Exception ex) { Trace.WriteLine("[readGAPinstance] Error:" + ex.Message); } Trace.WriteLine("Fine lettura dati istanza GAP"); }
public async void optimizeGAP() { if (P.checkFile()) { P.setGFromFile(); } else { double[] list = await getPrevisionsList("arima_forecast.py"); P.setGFromData(list); } P.readGAPinstance(this.dbPath); GAPclass G = P.getG(); double zub = G.simpleContruct(); Trace.WriteLine($"Constructive, zub = {zub}"); zub = G.opt10(G.c); Trace.WriteLine($"Local search, zub = {zub}"); zub = G.TabuSearch(30, 100); Trace.WriteLine($"Tabu search, zub = {zub}"); }
public Persistence(string dbpath) { this.dbpath = dbpath; this.factory = ""; this.G = new GAPclass(); }