Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4138


Ignore:
Timestamp:
08/03/10 14:51:53 (14 years ago)
Author:
svonolfe
Message:

The VRP problem now provides a random problem instance upon creation (#1085)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4118 r4138  
    210210      creator.VRPSolutionParameter.ActualName = "VRPSolution";
    211211      evaluator.QualityParameter.ActualName = "VRPQuality";
     212
     213      InitializeRandomVRPInstance();
     214
    212215      ParameterizeSolutionCreator();
    213216      ParameterizeEvaluator();
     
    482485      OnReset();
    483486    }
     487
     488    private void InitializeRandomVRPInstance() {
     489      System.Random rand = new System.Random();
     490
     491      int cities = 100;
     492
     493      Coordinates = new DoubleMatrix(cities + 1, 2);
     494      Demand = new DoubleArray(cities + 1);
     495      DueTime = new DoubleArray(cities + 1);
     496      ReadyTime = new DoubleArray(cities + 1);
     497      ServiceTime = new DoubleArray(cities + 1);
     498
     499      Vehicles.Value = 100;
     500      Capacity.Value = 200;
     501
     502      for (int i = 0; i <= cities; i++) {
     503        Coordinates[i, 0] = rand.Next(0, 100);
     504        Coordinates[i, 1] = rand.Next(0, 100);
     505
     506        if (i == 0) {
     507          Demand[i] = 0;
     508          DueTime[i] = Int16.MaxValue;
     509          ReadyTime[i] = 0;
     510          ServiceTime[i] = 0;
     511        } else {
     512          Demand[i] = rand.Next(10, 50);
     513          DueTime[i] = rand.Next((int)Math.Ceiling(CalculateDistance(0, i, Coordinates)), 1200);
     514          ReadyTime[i] = DueTime[i] - rand.Next(0, 100);
     515          ServiceTime[i] = 90;
     516        }
     517      }
     518    }
    484519  }
    485520}
Note: See TracChangeset for help on using the changeset viewer.