linopy.model.Model.copy#
- Model.copy(include_solution=False, deep=True)#
Return a copy of this model.
With
deep=True(default), variables, constraints, objective, parameters, blocks, and scalar attributes are copied to a fully independent model. Withdeep=False, returns a shallow copy.Model.copy()defaults to deep copy for workflow safety. In contrast,copy.copy(model)is shallow via__copy__, andcopy.deepcopy(model)is deep via__deepcopy__.Solver runtime metadata (for example,
solver_nameandsolver_model) is intentionally not copied. Solver backend state is recreated onsolve().- Parameters:
m (
Model) – The model to copy.include_solution (
bool, optional) – Whether to include solution and dual values in the copy. If False (default), solve artifacts are excluded: solution/dual data, objective value, and solve status are reset to initialized state. If True, these values are copied when present. For unsolved models, this has no additional effect.deep (
bool, optional) – Whether to return a deep copy (default) or shallow copy. If False, the returned model uses independent wrapper objects that share underlying data buffers with the source model.
- Returns:
Model– A deep or shallow copy of the model.