3
$\begingroup$

I am currently following this guide in the hopes of building a linear programming model in python and solving using gurobi.

https://towardsdatascience.com/schedule-optimisation-using-linear-programming-in-python-9b3e1bc241e1 However, when using his generate disjunctions function on my data set, it has taken over 12 hours to complete with unknown progress

   def _generate_disjunctions(self):
    """
    #TODO
    Returns:
        disjunctions (list): list of tuples containing disjunctions
    """
    cases = self.df_cases["CaseID"].to_list()
    sessions = self.df_sessions["SessionID"].to_list()
    disjunctions = []
    for (case1, case2, session) in product(cases, cases, sessions):
        if (case1 != case2) and (case2, case1, session) not in disjunctions:
            disjunctions.append((case1, case2, session))

    return disjunctions

For reference, my equivalent data set to cases is about 9000 long, and sessions is about 11000 long. I was wondering if there was any way I could improve this code or replace it with something else that could speed up the process.

$\endgroup$
2
  • $\begingroup$ Not sure if this works outside the given function, but can you make disjunctions a set, rather than a list? That'd already help a lot with the membership check. $\endgroup$
    – Nelewout
    Commented Oct 7, 2022 at 14:41
  • $\begingroup$ Seven, A 2nd Rob explains that the other Rob edited, the "reply" was from @Nelewout; to reply to them place an @ in front of their user name. $\endgroup$
    – Rob
    Commented Oct 7, 2022 at 16:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.