Skip to content

Use set() instead of [] for var_ids in Solver #28

@Prunoideae

Description

@Prunoideae

def __init__(self, model=None):
self.problem = None
self.var_ids = []
self.constr_ids = []
self.model = model

Will make add_variable to have performance regression if over 40k variables are added into the problem, and adding 200k variables will have 10mins overhead due to the query of a python list is O(n):

image

While replacing it with set() will make it done within a second as the set is O(1) complexity:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions