Opened 6 years ago
Last modified 6 years ago
#20461 closed defect
Fixes for copying a MIP and its variables — at Version 3
Reported by: | mkoeppe | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.3 |
Component: | numerical | Keywords: | lp |
Cc: | dimpase, vdelecroix, jdemeyer, nbruin, chapoton | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Even after merging #20414, both copy
and (the identical) deepcopy
have weird semantics in relation to the MIPVariable
s in a problems -- because a MIP does not have an API to gain access to its variables; and trying to use the old MIPVariable
s with the copy is questionable and definitely broken if one creates new components of this variable, see #15159, #19523. Same when there's no explicit MIPVariable
and only the _default_mipvariable
is used via the problem's __getitem__
method:
sage: sage: p = MixedIntegerLinearProgram() sage: p[0] x_0 sage: q = copy(p) sage: q[0] x_0 sage: q[1] x_1 sage: sage: p.number_of_variables() 2 sage: sage: q.number_of_variables() 1
Here's a possible fix without having to change the whole design:
- a new
MixedIntegerLinearProgram.copy
method that takes anames
keyword argument, enabling this operation:sage: p.<x,y> = MixedIntegerLinearProgram() sage: q.<newx,newy> = p.copy()
and the less magical syntax
sage: q, newx, newy = p.copy([x, y])
copy
and__copy__
(and__deepcopy__
) should make a copy of _default_variable (this requires writing a__copy__
method forMIPVariable
)- if
MixedIntegerLinearProgram.new_variable
has been called, it should set a flag and then if__copy__
(or__deepcopy__
) are called, it should display a warning (deprecation??) and refer the user to the newcopy
method.
Change History (3)
comment:1 Changed 6 years ago by
- Description modified (diff)
comment:2 Changed 6 years ago by
comment:3 Changed 6 years ago by
- Description modified (diff)
Note: See
TracTickets for help on using
tickets.
Any thoughts on this proposal?