sktopt.core.optimizers.oc

class sktopt.core.optimizers.oc.OC_Config(dst_path: str = './result/pytests', interpolation: ~typing.Literal['SIMP'] = 'SIMP', record_times: int = 20, max_iters: int = 200, beta_eta: float = 0.5, eta: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, p: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, vol_frac: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, beta: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, filter_type: ~typing.Literal['spacial', 'helmholtz'] = 'helmholtz', filter_radius: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, E0: float = 210000000000.0, E_min: float = 210000000.0, rho_min: float = 0.01, rho_max: float = 1.0, restart: bool = False, restart_from: int = -1, export_img: bool = False, export_img_opaque: bool = False, design_dirichlet: bool = False, sensitivity_filter: bool = False, solver_option: ~typing.Literal['spsolve', 'cg_pyamg'] = 'spsolve', scaling: bool = False, n_joblib: int = 1, lambda_lower: float = 1e-07, lambda_upper: float = 10000000.0, percentile: ~sktopt.tools.scheduler.SchedulerConfig = <factory>, move_limit: ~sktopt.tools.scheduler.SchedulerConfig = <factory>)

Bases: DensityMethod_OC_Config

Optimality-Criteria (OC) configuration for density-based optimization.

This class specializes common_density.DensityMethod_OC_Config for OC-style updates. The material interpolation is fixed to SIMP, and the projection threshold eta is controlled via a sktopt.tools.SchedulerConfig.

interpolation

Material interpolation model. Fixed to “SIMP” for OC.

Type:

{“SIMP”}

eta

Threshold (η) used in Heaviside projection / update logic. The default keeps η constant at 0.5 using a Constant scheduler. Pass a custom scheduler to run continuation (e.g., Step from 0.7 → 0.3).

Type:

sktopt.tools.SchedulerConfig

Notes

  • Other continuation parameters (e.g., p, beta, vol_frac, filter_radius) are inherited from the parent config if present there.

  • To override eta from outside, provide a pre-built SchedulerConfig at construction time.

interpolation: Literal['SIMP'] = 'SIMP'
class sktopt.core.optimizers.oc.OC_Optimizer(cfg: OC_Config, tsk: TaskConfig)

Bases: DensityMethod

Topology optimization solver using the classic Optimality Criteria (OC) method. This class implements the standard OC algorithm for compliance minimization problems. It uses a multiplicative density update formula derived from Karush-Kuhn-Tucker (KKT) optimality conditions under volume constraints.

The update rule typically takes the form:

ρ_new = clamp(ρ * sqrt(-dC / λ), ρ_min, ρ_max)

where:
  • dC is the sensitivity of the compliance objective,

  • λ is a Lagrange multiplier for the volume constraint.

This method is widely used in structural optimization due to its simplicity, interpretability, and solid theoretical foundation.

Advantages

  • Simple and easy to implement

  • Intuitive update rule based on physical insight

  • Well-established and widely validated in literature

config

Configuration object specifying the interpolation method, volume fraction, continuation settings, filter radius, and other numerical parameters.

Type:

DensityMethodConfig

mesh, basis, etc.

FEM components required for simulation, including boundary conditions and loads.

Type:

inherited from common_density.DensityMethod

init_schedulers(export: bool = True)
rho_update(iter_num: int, rho_design_eles: ndarray, rho_projected: ndarray, dC_drho_design_eles: ndarray, u_dofs: ndarray, strain_energy_mean: ndarray, scaling_rate: ndarray, move_limit: float, eta: float, beta: float, rho_clip_lower: ndarray, rho_clip_upper: ndarray, percentile: float | None, elements_volume_design: ndarray, elements_volume_design_sum: float, vol_frac: float)
sktopt.core.optimizers.oc.bisection_with_projection(dC, rho_e, rho_min, rho_max, move_limit, eta, eps, vol_frac, beta, beta_eta, scaling_rate, rho_design_eles, rho_clip_lower, rho_clip_upper, elements_volume, elements_volume_sum, max_iter: int = 100, tolerance: float = 0.0001, l1: float = 1e-07, l2: float = 10000000.0)