Commit 96a209e4 authored by Tjerk Vreeken's avatar Tjerk Vreeken

Use Python 3's super() for DRY

parent f0cceab6
......@@ -136,7 +136,7 @@ We turn on ensemble mode by setting ``csv_ensemble_mode = True``:
The method ``pre()`` is already defined in RTC-Tools, but we would like to add
a line to it to create a variable for storing intermediate results. To do
this, we declare a new ``pre()`` method, call ``super(Example, self).pre()``
this, we declare a new ``pre()`` method, call ``super().pre()``
to ensure that the original method runs unmodified, and add in a variable
declaration to store our list of intermediate results. This variable is a
dict, reflecting the need to store results from multiple ensemble.
......
......@@ -188,7 +188,7 @@ methods.
The method ``pre()`` is already defined in RTC-Tools, but we would like to add
a line to it to create a variable for storing intermediate results. To do this,
we declare a new ``pre()`` method, call ``super(Example, self).pre()`` to ensure
we declare a new ``pre()`` method, call ``super().pre()`` to ensure
that the original method runs unmodified, and add in a variable declaration to
store our list of intermediate results:
......
......@@ -107,7 +107,7 @@ classes.
The method ``pre()`` is already defined in RTC-Tools, but we would like to add
a line to it to create a variable for storing intermediate results. To do this,
we declare a new ``pre()`` method, call ``super(Example, self).pre()`` to ensure
we declare a new ``pre()`` method, call ``super().pre()`` to ensure
that the original method runs unmodified, and add in a variable declaration to
store our list of intermediate results.
......
......@@ -17,7 +17,7 @@ class Example(CSVMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def path_constraints(self, ensemble_member):
# Call super() class to not overwrite default behaviour
constraints = super(Example, self).path_constraints(ensemble_member)
constraints = super().path_constraints(ensemble_member)
# Constrain the volume of storage between 380000 and 420000 m^3
constraints.append((self.state('storage.V'), 380000, 420000))
return constraints
......
......@@ -13,7 +13,7 @@ import numpy as np
class WaterVolumeRangeGoal(StateGoal):
def __init__(self, optimization_problem):
# Call super class first, and pass in the optimization problem
super(WaterVolumeRangeGoal, self).__init__(optimization_problem)
super().__init__(optimization_problem)
# Assign V_min and V_max the the target range
self.target_min = optimization_problem.get_timeseries('V_min')
self.target_max = optimization_problem.get_timeseries('V_max')
......@@ -41,7 +41,7 @@ class Example(GoalProgrammingMixin, ControlTreeMixin, CSVLookupTableMixin,
def pre(self):
# Do the standard preprocessing
super(Example, self).pre()
super().pre()
# Create a dict of empty lists for storing intermediate results from
# each ensemble
......@@ -82,7 +82,7 @@ class Example(GoalProgrammingMixin, ControlTreeMixin, CSVLookupTableMixin,
def control_tree_options(self):
# We want to modify the control tree options, so we override the default
# control_tree_options method. We call super() to get the default options
options = super(Example, self).control_tree_options()
options = super().control_tree_options()
# Change the branching_times list to only contain the fifth timestep
options['branching_times'] = [self.times()[5]]
return options
......@@ -111,7 +111,7 @@ class Example(GoalProgrammingMixin, ControlTreeMixin, CSVLookupTableMixin,
q_release_integral))
def post(self):
super(Example, self).post()
super().post()
for e_m in range(self.ensemble_size):
print('\n\nResults for Ensemble Member {}:'.format(e_m))
for priority, n_level_satisfied, q_release_integral in \
......@@ -123,7 +123,7 @@ class Example(GoalProgrammingMixin, ControlTreeMixin, CSVLookupTableMixin,
# Any solver options can be set here
def solver_options(self):
options = super(Example, self).solver_options()
options = super().solver_options()
# When mumps_scaling is not zero, errors occur. RTC-Tools does its own
# scaling, so mumps scaling is not critical. Proprietary HSL solvers
# do not exhibit this error.
......
......@@ -67,7 +67,7 @@ class Example(GoalProgrammingMixin, CSVMixin, ModelicaMixin,
# We want to add a few hard constraints to our problem. The goal
# programming mixin however also generates constraints (and objectives)
# from on our goals, so we have to call super() here.
constraints = super(Example, self).path_constraints(ensemble_member)
constraints = super().path_constraints(ensemble_member)
# Release through orifice downhill only. This constraint enforces the
# fact that water only flows downhill
......@@ -108,7 +108,7 @@ class Example(GoalProgrammingMixin, CSVMixin, ModelicaMixin,
def pre(self):
# Call super() class to not overwrite default behaviour
super(Example, self).pre()
super().pre()
# We keep track of our intermediate results, so that we can print some
# information about the progress of goals at the end of our run.
self.intermediate_results = []
......@@ -134,7 +134,7 @@ class Example(GoalProgrammingMixin, CSVMixin, ModelicaMixin,
def post(self):
# Call super() class to not overwrite default behaviour
super(Example, self).post()
super().post()
for priority, n_level_satisfied, q_pump_integral, q_pump_sum_changes \
in self.intermediate_results:
print('\nAfter finishing goals of priority {}:'.format(priority))
......@@ -145,7 +145,7 @@ class Example(GoalProgrammingMixin, CSVMixin, ModelicaMixin,
# Any solver options can be set here
def solver_options(self):
options = super(Example, self).solver_options()
options = super().solver_options()
options['print_level'] = 1
return options
......
......@@ -16,7 +16,7 @@ class WaterVolumeRangeGoal(StateGoal):
# this goal.
def __init__(self, optimization_problem):
# Call super class first, and pass in the optimization problem
super(WaterVolumeRangeGoal, self).__init__(optimization_problem)
super().__init__(optimization_problem)
# Assign V_min and V_max the the target range
self.target_min = optimization_problem.get_timeseries('V_min')
self.target_max = optimization_problem.get_timeseries('V_max')
......@@ -41,7 +41,7 @@ class Example(GoalProgrammingMixin, CSVLookupTableMixin, CSVMixin,
"""
def pre(self):
super(Example, self).pre()
super().pre()
# Empty list for storing intermediate_results
self.intermediate_results = []
......@@ -91,7 +91,7 @@ class Example(GoalProgrammingMixin, CSVLookupTableMixin, CSVMixin,
def post(self):
# Call super() class to not overwrite default behaviour
super(Example, self).post()
super().post()
for priority, n_level_satisfied, q_release_integral in self.intermediate_results:
print("\nAfter finishing goals of priority {}:".format(priority))
print("Volume goal satisfied at {} of {} time steps".format(
......@@ -100,7 +100,7 @@ class Example(GoalProgrammingMixin, CSVLookupTableMixin, CSVMixin,
# Any solver options can be set here
def solver_options(self):
options = super(Example, self).solver_options()
options = super().solver_options()
options['print_level'] = 1
return options
......
......@@ -24,7 +24,7 @@ class Example(CSVMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
# Timeseries rather than a single number.
def path_constraints(self, ensemble_member):
# Call super to get default constraints
constraints = super(Example, self).path_constraints(ensemble_member)
constraints = super().path_constraints(ensemble_member)
# M is a handy big number
M = 1e10
......@@ -54,7 +54,7 @@ class Example(CSVMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
# Any solver options can be set here
def solver_options(self):
options = super(Example, self).solver_options()
options = super().solver_options()
# Restrict solver output
options['print_level'] = 1
return options
......
......@@ -143,7 +143,7 @@ class DiagHandler(logging.Handler):
def close(self):
self.flush()
super(DiagHandler, self).close()
super().close()
class ParameterConfig:
......
......@@ -66,11 +66,11 @@ class CSVLookupTableMixin(OptimizationProblem):
self._lookup_table_folder = kwargs['lookup_table_folder']
# Call parent
super(CSVLookupTableMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
def pre(self):
# Call parent class first for default behaviour.
super(CSVLookupTableMixin, self).pre()
super().pre()
# Get curve fitting options from curvefit_options.ini file
ini_path = os.path.join(
......
......@@ -57,11 +57,11 @@ class CSVMixin(OptimizationProblem):
self._output_timeseries = set()
# Call parent class first for default behaviour.
super(CSVMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
def pre(self):
# Call parent class first for default behaviour.
super(CSVMixin, self).pre()
super().pre()
# Helper function to check if initiale state array actually defines
# only the initial state
......@@ -180,7 +180,7 @@ class CSVMixin(OptimizationProblem):
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super(CSVMixin, self).parameters(ensemble_member)
parameters = super().parameters(ensemble_member)
# Load parameters from parameter config
for parameter in self.dae_variables['parameters']:
......@@ -217,7 +217,7 @@ class CSVMixin(OptimizationProblem):
@cached
def bounds(self):
# Call parent class first for default values.
bounds = super(CSVMixin, self).bounds()
bounds = super().bounds()
# Load bounds from timeseries
for variable in self.dae_variables['free_variables']:
......@@ -263,7 +263,7 @@ class CSVMixin(OptimizationProblem):
@cached
def initial_state(self, ensemble_member):
# Call parent class first for default values.
initial_state = super(CSVMixin, self).initial_state(ensemble_member)
initial_state = super().initial_state(ensemble_member)
# Load parameters from parameter config
for variable in self.dae_variables['free_variables']:
......@@ -280,7 +280,7 @@ class CSVMixin(OptimizationProblem):
@cached
def seed(self, ensemble_member):
# Call parent class first for default values.
seed = super(CSVMixin, self).seed(ensemble_member)
seed = super().seed(ensemble_member)
# Load seed values from CSV
for variable in self.dae_variables['free_variables']:
......@@ -299,7 +299,7 @@ class CSVMixin(OptimizationProblem):
def post(self):
# Call parent class first for default behaviour.
super(CSVMixin, self).post()
super().post()
# Write output
times = self.times()
......@@ -378,7 +378,7 @@ class CSVMixin(OptimizationProblem):
@property
def output_variables(self):
variables = super(CSVMixin, self).output_variables
variables = super().output_variables
variables.extend([MX.sym(variable)
for variable in self._output_timeseries])
return variables
......
......@@ -281,7 +281,7 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
def __init__(self, **kwargs):
# Call parent class first for default behaviour.
super(GoalProgrammingMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
# Initialize empty lists, so that the overridden methods may be called outside of the goal programming loop,
# for example in pre().
......@@ -301,7 +301,7 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
return self._subproblem_path_epsilons + [variable for (variable, value) in self._subproblem_path_timeseries]
def bounds(self):
bounds = super(GoalProgrammingMixin, self).bounds()
bounds = super().bounds()
for epsilon in self._subproblem_epsilons + self._subproblem_path_epsilons:
bounds[epsilon.name()] = (0.0, 1.0)
for (variable, value) in self._subproblem_path_timeseries:
......@@ -312,7 +312,7 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
def seed(self, ensemble_member):
if self._first_run:
seed = super(GoalProgrammingMixin, self).seed(ensemble_member)
seed = super().seed(ensemble_member)
else:
# Seed with previous results
seed = AliasDict(self.alias_relation)
......@@ -348,20 +348,20 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
return MX(0)
def constraints(self, ensemble_member):
constraints = super(GoalProgrammingMixin, self).constraints(ensemble_member)
constraints = super().constraints(ensemble_member)
for l in self._subproblem_constraints[ensemble_member].values():
constraints.extend(((constraint.function(self), constraint.min, constraint.max) for constraint in l))
return constraints
def path_constraints(self, ensemble_member):
path_constraints = super(GoalProgrammingMixin, self).path_constraints(ensemble_member)
path_constraints = super().path_constraints(ensemble_member)
for l in self._subproblem_path_constraints[ensemble_member].values():
path_constraints.extend(((constraint.function(self), constraint.min, constraint.max) for constraint in l))
return path_constraints
def solver_options(self):
# Call parent
options = super(GoalProgrammingMixin, self).solver_options()
options = super().solver_options()
# Make sure constant states, such as min/max timeseries for violation variables,
# are turned into parameters for the final optimization problem.
......@@ -805,7 +805,7 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
goal, epsilon, ensemble_member, options, min_series, max_series)
# Solve subproblem
success = super(GoalProgrammingMixin, self).optimize(
success = super().optimize(
preprocessing=False, postprocessing=False, log_solver_failure_as_error=log_solver_failure_as_error)
if not success:
break
......@@ -937,4 +937,4 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass = ABCMeta):
# If self._results is not up to date, do the super().extract_results
# method
return super(GoalProgrammingMixin, self).extract_results(ensemble_member)
return super().extract_results(ensemble_member)
......@@ -24,7 +24,7 @@ class HomotopyMixin(OptimizationProblem):
"""
def seed(self, ensemble_member):
seed = super(HomotopyMixin, self).seed(ensemble_member)
seed = super().seed(ensemble_member)
if self._theta > 0:
# Add previous results to seed
# Do not override any previously seeded values, such as goal programming results.
......@@ -37,7 +37,7 @@ class HomotopyMixin(OptimizationProblem):
return seed
def parameters(self, ensemble_member):
parameters = super(HomotopyMixin, self).parameters(ensemble_member)
parameters = super().parameters(ensemble_member)
options = self.homotopy_options()
parameters[options['homotopy_parameter']] = self._theta
......@@ -87,7 +87,7 @@ class HomotopyMixin(OptimizationProblem):
while self._theta <= 1.0:
logger.info("Solving with homotopy parameter theta = {}.".format(self._theta))
success = super(HomotopyMixin, self).optimize(preprocessing=False, postprocessing=False, log_solver_failure_as_error=False)
success = super().optimize(preprocessing=False, postprocessing=False, log_solver_failure_as_error=False)
if success:
self._results = [self.extract_results(ensemble_member) for ensemble_member in range(self.ensemble_size)]
......
......@@ -70,7 +70,7 @@ class InitialStateEstimationMixin(GoalProgrammingMixin):
return []
def goals(self):
g = super(InitialStateEstimationMixin, self).goals()
g = super().goals()
for measurement in self.initial_state_measurements():
g.append(_MeasurementGoal(*measurement))
......
......@@ -15,7 +15,7 @@ class LinearizationMixin(OptimizationProblem):
"""
def parameters(self, ensemble_member):
parameters = super(LinearizationMixin, self).parameters(ensemble_member)
parameters = super().parameters(ensemble_member)
for parameter, timeseries_id in self.linearization_parameters().items():
parameters[parameter] = self.timeseries_at(timeseries_id, self.initial_time, ensemble_member)
......
......@@ -108,7 +108,7 @@ class ModelicaMixin(OptimizationProblem):
self._nominals = {}
self._discrete = {}
for v in itertools.chain(self._pymola_model.states, self._pymola_model.alg_states, self._pymola_model.inputs):
sym_name = v.symbol.name()
sym_name = v.symbol.name()
if v.nominal != 0 and v.nominal != 1:
self._nominals[sym_name] = abs(float(v.nominal))
......@@ -131,7 +131,7 @@ class ModelicaMixin(OptimizationProblem):
self._initial_residual = MX()
# Call parent class first for default behaviour.
super(ModelicaMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
@cached
def compiler_options(self):
......@@ -173,7 +173,7 @@ class ModelicaMixin(OptimizationProblem):
return compiler_options
def delayed_feedback(self):
delayed_feedback = super(ModelicaMixin, self).delayed_feedback()
delayed_feedback = super().delayed_feedback()
delayed_feedback.extend([(dfb.origin, dfb.name, dfb.delay) for dfb in self._pymola_model.delayed_states])
return delayed_feedback
......@@ -192,7 +192,7 @@ class ModelicaMixin(OptimizationProblem):
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super(ModelicaMixin, self).parameters(ensemble_member)
parameters = super().parameters(ensemble_member)
# Return parameter values from pymola model
for v in self._pymola_model.parameters:
......@@ -204,7 +204,7 @@ class ModelicaMixin(OptimizationProblem):
@cached
def constant_inputs(self, ensemble_member):
# Call parent class first for default values.
constant_inputs = super(ModelicaMixin, self).constant_inputs(ensemble_member)
constant_inputs = super().constant_inputs(ensemble_member)
# Return input values from pymola model
times = self.times()
......@@ -248,7 +248,7 @@ class ModelicaMixin(OptimizationProblem):
@cached
def bounds(self):
# Call parent class first for default values.
bounds = super(ModelicaMixin, self).bounds()
bounds = super().bounds()
# Parameter values
parameters = self.parameters(0)
......
......@@ -62,11 +62,11 @@ class PIMixin(OptimizationProblem):
self._output_timeseries = set()
# Call parent class first for default behaviour.
super(PIMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
def pre(self):
# Call parent class first for default behaviour.
super(PIMixin, self).pre()
super().pre()
# rtcParameterConfig
self._parameter_config = []
......@@ -139,7 +139,7 @@ class PIMixin(OptimizationProblem):
def solver_options(self):
# Call parent
options = super(PIMixin, self).solver_options()
options = super().solver_options()
# Only do this if we have a rtcParameterConfig_Numerical
if self._parameter_config_numerical is None:
......@@ -155,7 +155,7 @@ class PIMixin(OptimizationProblem):
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super(PIMixin, self).parameters(ensemble_member)
parameters = super().parameters(ensemble_member)
# Load parameters from parameter config
for parameter_config in self._parameter_config:
......@@ -177,7 +177,7 @@ class PIMixin(OptimizationProblem):
@cached
def constant_inputs(self, ensemble_member):
# Call parent class first for default values.
constant_inputs = super(PIMixin, self).constant_inputs(ensemble_member)
constant_inputs = super().constant_inputs(ensemble_member)
# Load bounds from timeseries
for variable in self.dae_variables['constant_inputs']:
......@@ -198,7 +198,7 @@ class PIMixin(OptimizationProblem):
@cached
def bounds(self):
# Call parent class first for default values.
bounds = super(PIMixin, self).bounds()
bounds = super().bounds()
# Load bounds from timeseries
for variable in self.dae_variables['free_variables']:
......@@ -269,7 +269,7 @@ class PIMixin(OptimizationProblem):
@cached
def seed(self, ensemble_member):
# Call parent class first for default values.
seed = super(PIMixin, self).seed(ensemble_member)
seed = super().seed(ensemble_member)
# Load seeds
for variable in self.dae_variables['free_variables']:
......@@ -288,7 +288,7 @@ class PIMixin(OptimizationProblem):
def post(self):
# Call parent class first for default behaviour.
super(PIMixin, self).post()
super().post()
# Start of write output
# Write the time range for the export file.
......@@ -430,7 +430,7 @@ class PIMixin(OptimizationProblem):
@property
def output_variables(self):
variables = super(PIMixin, self).output_variables
variables = super().output_variables
variables.extend([MX.sym(variable)
for variable in self._output_timeseries])
return variables
......
......@@ -43,11 +43,11 @@ class CSVMixin(SimulationProblem):
self._output_folder = kwargs['output_folder']
# Call parent class first for default behaviour.
super(CSVMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
def pre(self):
# Call parent class first for default behaviour.
super(CSVMixin, self).pre()
super().pre()
# Helper function to check if initiale state array actually defines
# only the initial state
......@@ -144,7 +144,7 @@ class CSVMixin(SimulationProblem):
self._output = {variable : np.full(n_times, np.nan) for variable in self._output_variables}
# Call super, which will also initialize the model itself
super(CSVMixin, self).initialize(config_file)
super().initialize(config_file)
# Extract consistent t0 values
for variable in self._output_variables:
......@@ -156,7 +156,7 @@ class CSVMixin(SimulationProblem):
dt = self._dt
# Current time stamp
t = self.get_current_time()
t = self.get_current_time()
# Get current time index
t_idx = bisect.bisect_left(self._timeseries_times_sec, t + dt)
......@@ -169,7 +169,7 @@ class CSVMixin(SimulationProblem):
self.set_var(variable, value)
# Call super
super(CSVMixin, self).update(dt)
super().update(dt)
# Extract results
for variable in self._output_variables:
......@@ -177,7 +177,7 @@ class CSVMixin(SimulationProblem):
def post(self):
# Call parent class first for default behaviour.
super(CSVMixin, self).post()
super().post()
# Write output
names = ['time'] + sorted(set(self._output.keys()))
......
......@@ -53,11 +53,11 @@ class PIMixin(SimulationProblem):
self._data_config = rtc.DataConfig(self._input_folder)
# Call parent class first for default behaviour.
super(PIMixin, self).__init__(**kwargs)
super().__init__(**kwargs)
def pre(self):
# Call parent class first for default behaviour.
super(PIMixin, self).pre()
super().pre()
# rtcParameterConfig
self._parameter_config = []
......@@ -142,7 +142,7 @@ class PIMixin(SimulationProblem):
self._output = {variable : np.full(n_times, np.nan) for variable in self._output_variables}
# Call super, which will also initialize the model itself
super(PIMixin, self).initialize(config_file)
super().initialize(config_file)
# Extract consistent t0 values
for variable in self._output_variables:
......@@ -167,7 +167,7 @@ class PIMixin(SimulationProblem):
self.set_var(variable, value)
# Call super
super(PIMixin, self).update(dt)
super().update(dt)
# Extract results
for variable in self._output_variables:
......@@ -175,7 +175,7 @@ class PIMixin(SimulationProblem):
def post(self):
# Call parent class first for default behaviour.
super(PIMixin, self).post()
super().post()
# Start of write output
# Write the time range for the export file.
......
......@@ -19,7 +19,7 @@ logger.setLevel(logging.DEBUG)
class TestProblem(ControlTreeMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self, branching_times):
super(TestProblem, self).__init__(
super().__init__(
model_name='TestModelWithInitial', model_folder=data_path())
self._branching_times = branching_times
......@@ -130,7 +130,7 @@ class TestControlTreeMixin5(TestControlTreeMixin1):
class TestProblemDijkverruiming(ControlTreeMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self):
super(TestProblemDijkverruiming, self).__init__(
super().__init__(
model_name='TestModelWithInitial', model_folder=data_path())
def times(self, variable=None):
......
......@@ -24,7 +24,7 @@ class TestProblem(CSVMixin, ModelicaMixin, CollocatedIntegratedOptimizationProbl
kwargs['input_folder'] = data_path()
kwargs['output_folder'] = data_path()
kwargs['model_folder'] = data_path()
super(TestProblem, self).__init__(**kwargs)
super().__init__(**kwargs)
def delayed_feedback(self):
# Delayed feedback
......@@ -49,7 +49,7 @@ class TestProblem(CSVMixin, ModelicaMixin, CollocatedIntegratedOptimizationProbl
class TestProblemLookup(CSVLookupTableMixin, TestProblem):
def __init__(self):
super(TestProblemLookup, self).__init__(input_folder=data_path(), output_folder=data_path(
super().__init__(input_folder=data_path(), output_folder=data_path(
), model_name='TestModel', model_folder=data_path(), lookup_tables=['constant_input'])
......@@ -58,7 +58,7 @@ class TestProblemEnsemble(TestProblem):
csv_ensemble_mode = True
def __init__(self):
super(TestProblemEnsemble, self).__init__(input_folder=data_path(), output_folder=data_path(
super().__init__(input_folder=data_path(), output_folder=data_path(
), model_name='TestModel', model_folder=data_path(), lookup_tables=[])
......
......@@ -20,7 +20,7 @@ logger.setLevel(logging.WARNING)
class TestProblem(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self):
super(TestProblem, self).__init__(input_folder=data_path(), output_folder=data_path(
super().__init__(input_folder=data_path(), output_folder=data_path(
), model_name='TestModelWithInitial', model_folder=data_path())
def times(self, variable=None):
......@@ -37,7 +37,7 @@ class TestProblem(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegratedOptim
return {'constant_input': Timeseries(np.hstack(([self.initial_time, self.times()])), np.hstack(([1.0], np.linspace(1.0, 0.0, 21))))}
def bounds(self):
bounds = super(TestProblem, self).bounds()
bounds = super().bounds()
bounds['u'] = (-2.0, 2.0)
return bounds
......@@ -247,7 +247,7 @@ class PathGoal5(Goal):
class TestProblemPathGoals(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self):
super(TestProblemPathGoals, self).__init__(input_folder=data_path(
super().__init__(input_folder=data_path(
), output_folder=data_path(), model_name='TestModelWithInitial', model_folder=data_path())
def times(self, variable=None):
......@@ -264,7 +264,7 @@ class TestProblemPathGoals(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegr
return {'constant_input': Timeseries(np.hstack(([self.initial_time, self.times()])), np.hstack(([1.0], np.linspace(1.0, 0.0, 21))))}
def bounds(self):
bounds = super(TestProblemPathGoals, self).bounds()
bounds = super().bounds()
bounds['u'] = (-2.0, 2.0)
return bounds
......@@ -423,7 +423,7 @@ class PathGoalSmoothing(Goal):
class TestProblemPathGoalsSmoothing(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self):
super(TestProblemPathGoalsSmoothing, self).__init__(input_folder=data_path(
super().__init__(input_folder=data_path(
), output_folder=data_path(), model_name='TestModelWithInitial', model_folder=data_path())
def times(self, variable=None):
......@@ -440,7 +440,7 @@ class TestProblemPathGoalsSmoothing(GoalProgrammingMixin, ModelicaMixin, Colloca
return {'constant_input': Timeseries(np.hstack(([self.initial_time, self.times()])), np.hstack(([1.0], np.linspace(1.0, 0.0, 21))))}
def bounds(self):
bounds = super(TestProblemPathGoalsSmoothing, self).bounds()
bounds = super().bounds()
bounds['u'] = (-2.0, 2.0)
return bounds
......@@ -493,7 +493,7 @@ class StateGoal3(StateGoal):
class TestProblemStateGoals(GoalProgrammingMixin, ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self):
super(TestProblemStateGoals, self).__init__(input_folder=data_path(
super().__init__(input_folder=data_path(
), output_folder=data_path(), model_name='TestModelWithInitial', model_folder=data_path())
def times(self, variable=None):
......@@ -510,7 +510,7 @@ class TestProblemStateGoals(GoalProgrammingMixin, ModelicaMixin, CollocatedInteg
return {'constant_input': Timeseries(np.hstack(([self.initial_time, self.times()])), np.hstack(([1.0], np.linspace(1.0, 0.0, 21))))}
def bounds(self):
bounds = super(TestProblemStateGoals, self).bounds()
bounds = super().bounds()
bounds['u'] = (-2.0, 2.0)
bounds['x'] = (-10, 10)
return bounds
......
......@@ -17,7 +17,7 @@ logger = logging.getLogger("rtctools")
class HybridShootingTestProblem(ModelicaMixin, CollocatedIntegratedOptimizationProblem):
def __init__(self, integrated_states):
super(HybridShootingTestProblem, self).__init__(input_folder=data_path(
super().__init__(input_folder=data_path(