Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14642 for branches


Ignore:
Timestamp:
02/03/17 09:15:44 (8 years ago)
Author:
abeham
Message:

#2205: added disposal of errorhandler and datasource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Problems.FacilityLocation.CplexSolver/3.3/FLPCplexSolver.cs

    r14595 r14642  
    8484      var cplex = factory.CreateCplex();
    8585
    86       var errorHandler = factory.CreateOplErrorHandler();
    8786
    88       var dataSource = new FLPDataSource(factory, Problem);
    8987      var model = Assembly.GetExecutingAssembly().GetManifestResourceNames().SingleOrDefault(x => x.EndsWith(@".FLP.mod"));
    9088      var modelStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(model);
     
    9593      using (var reader = new StreamReader(modelStream))
    9694      using (var modelSource = factory.CreateOplModelSourceFromString(reader.ReadToEnd(), Path.GetFileNameWithoutExtension(model)))
     95      using (var errorHandler = factory.CreateOplErrorHandler())
    9796      using (var settings = factory.CreateOplSettings(errorHandler))
    9897      using (var def = factory.CreateOplModelDefinition(modelSource, settings))
    99       using (var opl = factory.CreateOplModel(def, cplex)) {
     98      using (var opl = factory.CreateOplModel(def, cplex))
     99      using (var dataSource = new FLPDataSource(factory, Problem)) {
    100100        opl.AddDataSource(dataSource);
    101101        opl.Generate();
    102102        cplex.SetParam(Cplex.DoubleParam.TiLim, MaximumRuntimeParameter.Value.Value.TotalSeconds);
    103         //cplex.ExportModel("model.lp");
    104         //opl.ConvertAllIntVars();
    105103        var solved = cplex.Solve();
    106104        var assignment = new IntegerVector(customers);
     
    113111
    114112          var sol = opl.GetElement(FLPDataSource.CustomerDepotAssignment).AsIntMap();
    115          
     113
    116114          for (var i = 0; i < depots; i++) {
    117115            var solI = sol.GetSub(i);
Note: See TracChangeset for help on using the changeset viewer.