@Override public boolean register(SolverUser element) { element.setSolverProvider(new Provider()); return true; }
CentralModel(Clock c, PDPRoadModel rm, PDPModel pm, Solver solver) { roadModel = rm; solverAdapter = Solvers.solverBuilder(solver) .with(rm) .with(pm) .with(c) .build(); }
@Override public ImmutableList<ImmutableList<Parcel>> solve(GlobalStateObject state) throws InterruptedException { return validateOutputs(delegateSolver.solve(validateInputs(state)), state); } }
/** * Calls the {@link Solver} to solve the problem as defined by the current * simulation state. * @param args {@link SolveArgs} specifying what information to include. * @return A list containing routes for each vehicle known to this solver. */ public ImmutableList<ImmutableList<Parcel>> solve(SolveArgs args) { return solve(convert(args)); }
@Override public RtSimSolverBuilder setVehicles(Set<? extends Vehicle> vehicles) { delegate.setVehicles(vehicles); return this; }
@Override public ImmutableList<ImmutableList<Parcel>> call() throws Exception { return solver.solve(snapshot); } }
public GlobalStateObject build() { return SolverValidator.validateInputs(buildUnsafe()); }
/** * Provides a {@link MASConfiguration} that configures a MAS that is * controlled centrally by a {@link Solver}. * @param solverCreator The solver creator to use for instantiating solvers. * @return A new configuration. */ public static MASConfiguration solverConfiguration( StochasticSupplier<? extends Solver> solverCreator) { return solverConfiguration(solverCreator, ""); }
/** * Creates a builder for creating {@link SimSolver} instances. For more * information see {@link AdapterBuilder}. * @param sol The solver to use internally. * @return The builder. */ public static AdapterBuilder<SimSolver> solverBuilder(Solver sol) { return new AdapterBuilder<>(sol); }
Builder() { setDependencies(Clock.class, PDPRoadModel.class, PDPModel.class, RandomProvider.class); }
/** * Create a new instance. * @param input The input problem as given to the solver. * @param dur The duration it took to find a solution for the input. * @return A new instance. */ public static SolverTimeMeasurement create(GlobalStateObject input, long dur) { return new AutoValue_SolverTimeMeasurement(input, dur); } }
/** * @return A new {@link Builder} instance. */ public static Builder builder() { return Builder.create(); }
static GlobalStateObject create(ImmutableSet<Parcel> availableParcels, ImmutableList<VehicleStateObject> vehicles, long time, Unit<Duration> timeUnit, Unit<Velocity> speedUnit, Unit<Length> distUnit, RoadModelSnapshot snapshot) { return new AutoValue_GlobalStateObject( availableParcels, vehicles, time, timeUnit, speedUnit, distUnit, snapshot); }
@SuppressWarnings("unchecked") static Builder create(StochasticSupplier<? extends Solver> solverSupplier) { return new AutoValue_Central_Builder( (StochasticSupplier<Solver>) solverSupplier); } }
/** * Wraps the specified solver in a {@link SolverDebugger} instance to allow * easier debugging of a solver. * @param s The solver to wrap. * @param print Whether debug printing should be enabled. * @return The wrapped solver. */ public static SolverDebugger wrap(Solver s, boolean print) { return new SolverDebugger(s, print); } }
/** * Decorates the original {@link Solver} such that both the inputs to the * solver and the outputs from the solver are validated. When an invalid input * or output is detected a {@link IllegalArgumentException} is thrown. * @param delegate The {@link Solver} that will be used for the actual * solving. * @return The wrapped solver. */ public static Solver wrap(Solver delegate) { return new SolverValidator.ValidatedSolver(delegate); }
/** * Creates a new builder for creating a central model. * @param solverSupplier The solver to use. * @return A new instance. */ public static ModelBuilder<?, ?> builder( StochasticSupplier<? extends Solver> solverSupplier) { return Builder.create(solverSupplier); }
/** * @return {@link SolveArgs} builder. */ public static SolveArgs create() { return new SolveArgs(); }
/** * Decorates the original {@link StochasticSupplier} such that all generated * {@link Solver} instances are wrapped using {@link #wrap(Solver)}. * @param sup The supplier to wrap. * @return The wrapper supplier. */ public static StochasticSupplier<Solver> wrap( StochasticSupplier<? extends Solver> sup) { return new ValidatedSupplier(sup); }
/** * Creates a builder for creating {@link SimulationConverter} instances. * @return The builder. */ public static AdapterBuilder<SimulationConverter> converterBuilder() { return new AdapterBuilder<>(null); }