class TopoSolver[source]

TopoSolver(device:str='cpu', name:str=None, trainable:bool=False, differentiable:bool=False)

A parent class that inherits all kinds of topo solvers, i.e., algorithms that solve the topology optimization task.

Type Default Details
device str cpu The device of the topo solver. Can bei either "cpu" or "cuda".
name str None The name of the topo solver.
trainable bool False Whether the topo solver is trainable.
differentiable bool False Whether the topo solver is differentiable.

TopoSolver.to[source]

TopoSolver.to(device:str)

Move the topo solver to device.

Type Default Details
device str The device of the topo solver. Can bei either "cpu" or "cuda".

TopoSolver.cuda[source]

TopoSolver.cuda()

Move the topo solver to cuda.

TopoSolver.cpu[source]

TopoSolver.cpu()

Move the topo solver to cpu.

TopoSolver.clone[source]

TopoSolver.clone()

Return a dl4to.topo_solvers.TopoSolver object, which is clone of the current topo solver.

TopoSolver.__call__[source]

TopoSolver.__call__(problems_or_solutions:list, eval_mode:bool=True)

Perform a forward pass of the topo solver. Expects a list of problems or solutions. Returns a dl4to.solution.Solution object or a list of solutions, if the input was also a list.

Type Default Details
problems_or_solutions list A list containing problem and solution objects.
eval_mode bool True Determines whether to calculate gradients for the backwards pass or not. If True, then no gradients are calculated.

TopoSolver.eval[source]

TopoSolver.eval(root:str, criteria:list, dataloader:DataLoader)

Evalate criteria with outputs from the topo solver. Returns a collections.defaultdict dictionary.

Type Default Details
root str The root directory where the evaluation results are saved.
criteria list A list of dl4to.criteria.Criterion objects that are used for the evaluation.
dataloader DataLoader The dataloader that is used for retrieving the validation data.

TopoSolver.plot_first_solutions_from_dataloader[source]

TopoSolver.plot_first_solutions_from_dataloader(root:str, n_plots:int, dataloader:DataLoader, camera_position:Union[tuple, list]=(0, 0.1, 0.12), export_png:bool=True)

Saves n_plots plots of solutions obtained via the topo_solver from problems from the dataloader.

Type Default Details
root str The root where the plots should be saved.
n_plots int The number of solutions to plot.
dataloader DataLoader The dataloader that is used to obtain the data.
camera_position typing.Union[tuple, list] (0, 0.1, 0.12) x, y, and z coordinates of the camera position.
export_png bool True Whether the figure is exported and saved as a png file, in addition to the standard html format.