[fix] Restores functionality of OptimizationDialog
This commit is contained in:
parent
a00636a1ed
commit
e33353cf68
@ -164,7 +164,12 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public FlightConfiguration getActiveConfiguration() {
|
||||
mutex.verify();
|
||||
return rocket.getFlightConfiguration(this.configId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the rocket associated with this simulation.
|
||||
*
|
||||
@ -185,7 +190,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
/**
|
||||
* Set the motor configuration ID. If this id does not yet exist, it will be created.
|
||||
*
|
||||
* @param id the configuration to set.
|
||||
* @param fcid the configuration to set.
|
||||
*/
|
||||
public void setFlightConfigurationId(FlightConfigurationId fcid) {
|
||||
if ( null == fcid ){
|
||||
@ -487,26 +492,29 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
/**
|
||||
* Create a duplicate of this simulation with the specified rocket. The new
|
||||
* simulation is in non-simulated state.
|
||||
* This methods performs
|
||||
* synchronization on the simulation for thread protection.
|
||||
* <p>
|
||||
* Note: This method is package-private for unit testing purposes.
|
||||
*
|
||||
* @param newRocket the rocket for the new simulation.
|
||||
* @return a new simulation with the same conditions and properties.
|
||||
* @return a new deep copy of the simulation and rocket with the same conditions and properties.
|
||||
*/
|
||||
public Simulation duplicateSimulation(Rocket newRocket) {
|
||||
mutex.lock("duplicateSimulation");
|
||||
try {
|
||||
Simulation copy = new Simulation(newRocket);
|
||||
|
||||
copy.name = this.name;
|
||||
copy.configId = this.configId;
|
||||
copy.options.copyFrom(this.options);
|
||||
copy.simulatedConfigurationDescription = this.simulatedConfigurationDescription;
|
||||
final Simulation newSim = new Simulation(newRocket);
|
||||
newSim.name = this.name;
|
||||
newSim.configId = this.configId;
|
||||
newSim.options.copyFrom(this.options);
|
||||
newSim.simulatedConfigurationDescription = this.simulatedConfigurationDescription;
|
||||
for (SimulationExtension c : this.simulationExtensions) {
|
||||
copy.simulationExtensions.add(c.clone());
|
||||
newSim.simulationExtensions.add(c.clone());
|
||||
}
|
||||
copy.simulationStepperClass = this.simulationStepperClass;
|
||||
copy.aerodynamicCalculatorClass = this.aerodynamicCalculatorClass;
|
||||
newSim.simulationStepperClass = this.simulationStepperClass;
|
||||
newSim.aerodynamicCalculatorClass = this.aerodynamicCalculatorClass;
|
||||
|
||||
return copy;
|
||||
return newSim;
|
||||
} finally {
|
||||
mutex.unlock("duplicateSimulation");
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ public class RocketOptimizationFunction implements Function {
|
||||
modifiers.length + " simulation modifiers");
|
||||
}
|
||||
|
||||
Simulation simulation = newSimulationInstance(baseSimulation);
|
||||
final Simulation simulation = newSimulationInstance(baseSimulation);
|
||||
|
||||
for (int i = 0; i < modifiers.length; i++) {
|
||||
modifiers[i].modify(simulation, p[i]);
|
||||
}
|
||||
|
||||
|
||||
// Check whether the point is within the simulation domain
|
||||
Pair<Double, Value> d = domain.getDistanceToDomain(simulation);
|
||||
double distance = d.getU();
|
||||
@ -106,7 +106,6 @@ public class RocketOptimizationFunction implements Function {
|
||||
return goalValue;
|
||||
}
|
||||
|
||||
|
||||
// Compute the optimization value
|
||||
parameterValue = parameter.computeValue(simulation);
|
||||
goalValue = goal.getMinimizationParameter(parameterValue);
|
||||
@ -118,34 +117,25 @@ public class RocketOptimizationFunction implements Function {
|
||||
goalValue = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
log.trace("Parameter value at point " + point + " is " + parameterValue + ", goal function value=" + goalValue);
|
||||
|
||||
fireEvent(simulation, point, referenceValue, new Value(parameterValue, parameter.getUnitGroup().getDefaultUnit()),
|
||||
goalValue);
|
||||
fireEvent( simulation, point, referenceValue,
|
||||
new Value(parameterValue, parameter.getUnitGroup().getDefaultUnit()),
|
||||
goalValue);
|
||||
|
||||
return goalValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new deep copy of the simulation and rocket. This methods performs
|
||||
* synchronization on the simulation for thread protection.
|
||||
* Returns a new deep copy of the simulation and rocket.
|
||||
* <p>
|
||||
* Note: This method is package-private for unit testing purposes.
|
||||
*
|
||||
* @return a new deep copy of the simulation and rocket
|
||||
*
|
||||
* @return a new deep copy of the simulation and rocket
|
||||
*/
|
||||
Simulation newSimulationInstance(Simulation simulation) {
|
||||
synchronized (baseSimulation) {
|
||||
Rocket newRocket = simulation.getRocket().copyWithOriginalID();
|
||||
return simulation.duplicateSimulation(newRocket);
|
||||
}
|
||||
return simulation.duplicateSimulation(simulation.getRocket().copyWithOriginalID());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a listener to this function. The listener will be notified each time the
|
||||
* function is successfully evaluated.
|
||||
|
@ -39,7 +39,8 @@ public class GenericComponentModifier extends GenericModifier<RocketComponent> {
|
||||
|
||||
@Override
|
||||
protected RocketComponent getModifiedObject(Simulation simulation) throws OptimizationException {
|
||||
RocketComponent c = simulation.getRocket().findComponent(componentId);
|
||||
final RocketComponent c = simulation.getRocket().findComponent(componentId);
|
||||
|
||||
if (c == null) {
|
||||
throw new OptimizationException("Could not find component of type " + componentClass.getSimpleName()
|
||||
+ " with correct ID");
|
||||
|
Loading…
x
Reference in New Issue
Block a user