bessagroup / f3dasm

Framework for Data-Driven Design & Analysis of Structures & Materials (F3DASM)
https://f3dasm.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
114 stars 31 forks source link

Suggestion to reduce complex structure in execution parts of the code #76

Closed h-vijayakumaran closed 1 year ago

h-vijayakumaran commented 1 year ago

I feel that some parts of the execution code are structured in a complex way, and the intuition might be lost to the reader. Referring to an example of multiple realizations of SGA from the tutorial practical_session_solutions.ipynb:


# Define the blocks:
dimensionality = 20
iterations = 600
realizations = 10
hyperparameters= {} # If none are selected, the default ones are used
domain = np.tile([-1., 1.], (dimensionality,1))
design = f3dasm.make_nd_continuous_design(bounds=domain, dimensionality=dimensionality)
data = f3dasm.Data(design)

# We can put them in a dictionary if we want
implementation = {
'realizations': realizations,
'optimizer': f3dasm.optimization.CMAES(data=data, hyperparameters=hyperparameters), 
'function': f3dasm.functions.Ackley(dimensionality=dimensionality, noise=False, scale_bounds=domain),
'sampler': f3dasm.sampling.LatinHypercubeSampling(design, seed=seed),
'iterations': iterations,
}

results = f3dasm.run_multiple_realizations(**implementation)

It would be helpful if there aren't many complex arguments of domain, design, and data (which take one another as argument for instantiation) used again in dictionary implementation.

mpvanderschelling commented 1 year ago

The run_multiple_realizations function has been simplified by being able to accept built-in arguments of f3dasm as strings (e.g. sampler='latin'.

The same goes for the optimizer and function arguments.

mpvanderschelling commented 1 year ago

FYI; in later versions of f3dasm this function will be deprecated; since this is a data-driven process on it's own.