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