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); } }
OptimizationSolver(OptimizationProblem optimizationProblem, OptimizationSubstitutions optimizationSubstitutions) { if (optimizationProblem == null) { throw new ArgumentNullException("optimizationProblem"); } if (optimizationSubstitutions == null) { throw new ArgumentNullException("optimizationSubstitutions"); } this.optimizationProblem = optimizationProblem; this.optimizationSubstitutions = optimizationSubstitutions; this.solver = new IpoptSolver(optimizationProblem.Problem.Substitute(optimizationSubstitutions.Substitutions), new Settings()); }
public static OptimizationSolver Create(OptimizationProblem optimizationProblem, OptimizationSubstitutions optimizationSubstitutions) { return(new OptimizationSolver(optimizationProblem, optimizationSubstitutions)); }
public bool NeedsRebuild(OptimizationProblem newOptimizationProblem, OptimizationSubstitutions newOptimizationSubstitutions) { return (optimizationProblem != newOptimizationProblem || optimizationSubstitutions != newOptimizationSubstitutions); }