Esempio n. 1
0
 void Rebuild(Specification specification)
 {
     if (optimizationSegments == null || optimizationSegments.NeedsRebuild(specification))
     {
         Console.WriteLine("Rebuilding OptimizationSegments...");
         optimizationSegments = OptimizationSegments.Create(specification);
     }
     if (optimizationProblem == null || optimizationProblem.NeedsRebuild(optimizationSegments, specification))
     {
         Console.WriteLine("Rebuilding OptimizationProblem...");
         optimizationProblem = OptimizationProblem.Create(optimizationSegments, specification);
     }
     if (optimizationSubstitutions == null || optimizationSubstitutions.NeedsRebuild(optimizationSegments, optimizationProblem, specification))
     {
         Console.WriteLine("Rebuilding OptimizationSubstitutions...");
         optimizationSubstitutions = OptimizationSubstitutions.Create(optimizationSegments, optimizationProblem, specification);
     }
     if (optimizationSolver == null || optimizationSolver.NeedsRebuild(optimizationProblem, optimizationSubstitutions))
     {
         Console.WriteLine("Rebuilding OptimizationSolver...");
         optimizationSolver = OptimizationSolver.Create(optimizationProblem, optimizationSubstitutions);
     }
     if (optimizationPosition == null || optimizationPosition.NeedsRebuild(optimizationSolver, specification.Position))
     {
         Console.WriteLine("Rebuilding OptimizationPosition...");
         optimizationPosition = OptimizationPosition.Create(optimizationSolver, specification.Position);
     }
 }
Esempio n. 2
0
        OptimizationPosition(OptimizationSolver optimizationSolver, IEnumerable <double> initialPosition)
        {
            if (optimizationSolver == null)
            {
                throw new ArgumentNullException("optimizationSolver");
            }
            if (initialPosition == null)
            {
                throw new ArgumentNullException("initialPosition");
            }

            this.optimizationSolver = optimizationSolver;
            this.initialPosition    = initialPosition;

            this.position = optimizationSolver.Solver.Solve(initialPosition);
        }
Esempio n. 3
0
 public static OptimizationPosition Create(OptimizationSolver optimizationSolver, IEnumerable <double> initialPosition)
 {
     return(new OptimizationPosition(optimizationSolver, initialPosition));
 }
Esempio n. 4
0
 public bool NeedsRebuild(OptimizationSolver newOptimizationSolver, IEnumerable <double> newInitialPosition)
 {
     return
         (optimizationSolver != newOptimizationSolver ||
          !Enumerable.SequenceEqual(initialPosition, newInitialPosition) && !Enumerable.SequenceEqual(position, newInitialPosition));
 }