public ActionResult ModelCoz() { var data = new TransportDataModel() { Fabrikalar = _fabrikaService.GetList(), Depolar = _depoService.GetList(), Maliyetler = _transportMaliyetService.GetList(), LowerBound = 0, UpperBound = 15 }; //if (data.Fabrikalar.Count<=3 && data.Depolar.Count <= 3) _transportService.Solve(data); //TempData["result"] = _blendOptimization.ResultMessage; var model = new TransportSonucIndexModel() { TransportSonucDetails = _transportSonucService.GetSonucDetails(null) }; //return View(model); return(RedirectToAction("Index", "TransportSonuc", new { area = "Optimization", model })); }
public TransportSonucModel Solve(TransportDataModel data) { var config = new Configuration { NameHandling = NameHandlingStyle.UniqueLongNames, ComputeRemovedVariables = true }; using (var scope = new ModelScope(config)) { DataModel = data; Model(); // Get a solver instance, change your solver var solver = new CplexSolver(); // solve the model var solution = solver.Solve(_model); // import the results back into the model _model.VariableCollections.ForEach(vc => vc.SetVariableValues(solution.VariableValues)); // print objective and variable decisions var objective = solution.ObjectiveValues.Single(); Results = new TransportSonucModel { ObjectiveValue = objective.Value, ResultModel = new List <TransportSonuc>() }; foreach (var r in DataModel.Maliyetler.Where(s => x[s].Value > 0)) { Results.ResultModel.Add(new TransportSonuc() { DepoId = r.DepoId, FabrikaId = r.FabrikaId, Sonuc = x[r].Value }); } } return(Results); }
public TransportSonucModel Solve(TransportDataModel data) { var _mevcutSonuclar = _transportSonucService.GetList(); Results = new TransportSonucModel(); Results = _transportOptimization.Solve(data); //önceki sonuçları sil foreach (var result in _mevcutSonuclar) { _transportSonucService.Delete(result.Id); } //yeni sonuçları ekle foreach (var result in Results.ResultModel) { _transportSonucService.Insert(result); } return(Results); }