From 6ace1be9853bbd2e77ca55ab56bbfced69756409 Mon Sep 17 00:00:00 2001 From: Alessandro Berti Date: Thu, 7 Nov 2024 07:47:21 +0100 Subject: [PATCH] removed deprecated code --- pm4py/util/lp/solver.py | 9 +- .../cvxopt_solver_custom_align_arm.py | 111 ------------------ 2 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 pm4py/util/lp/variants/cvxopt_solver_custom_align_arm.py diff --git a/pm4py/util/lp/solver.py b/pm4py/util/lp/solver.py index 4de177cdc..c1a8bb495 100644 --- a/pm4py/util/lp/solver.py +++ b/pm4py/util/lp/solver.py @@ -60,16 +60,9 @@ class Parameters(Enum): DEFAULT_LP_SOLVER_VARIANT = SCIPY if importlib.util.find_spec("cvxopt"): - from pm4py.util.lp.variants import cvxopt_solver, cvxopt_solver_custom_align, cvxopt_solver_custom_align_ilp, \ - cvxopt_solver_custom_align_arm + from pm4py.util.lp.variants import cvxopt_solver, cvxopt_solver_custom_align, cvxopt_solver_custom_align_ilp custom_solver = cvxopt_solver_custom_align - try: - # for ARM-based Linux, we need to use a different call to GLPK - if "arm" in str(os.uname()[-1]): - custom_solver = cvxopt_solver - except: - pass CVXOPT = "cvxopt" CVXOPT_SOLVER_CUSTOM_ALIGN = "cvxopt_solver_custom_align" diff --git a/pm4py/util/lp/variants/cvxopt_solver_custom_align_arm.py b/pm4py/util/lp/variants/cvxopt_solver_custom_align_arm.py deleted file mode 100644 index e86b3657a..000000000 --- a/pm4py/util/lp/variants/cvxopt_solver_custom_align_arm.py +++ /dev/null @@ -1,111 +0,0 @@ -''' - This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de). - - PM4Py is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - PM4Py is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PM4Py. If not, see . -''' -import sys - -from cvxopt import blas -from cvxopt import glpk - - -def custom_solve_lp(c, G, h, A, b): - status, x, z, y = glpk.lp(c, G, h, A, b) - - if status == 'optimal': - pcost = blas.dot(c, x) - else: - pcost = None - - return {'status': status, 'x': x, 'primal objective': pcost} - - -def apply(c, Aub, bub, Aeq, beq, parameters=None): - """ - Gets the overall solution of the problem - - Parameters - ------------ - c - c parameter of the algorithm - Aub - A_ub parameter of the algorithm - bub - b_ub parameter of the algorithm - Aeq - A_eq parameter of the algorithm - beq - b_eq parameter of the algorithm - parameters - Possible parameters of the algorithm - - Returns - ------------- - sol - Solution of the LP problem by the given algorithm - """ - sol = custom_solve_lp(c, Aub, bub, Aeq, beq) - - return sol - - -def get_prim_obj_from_sol(sol, parameters=None): - """ - Gets the primal objective from the solution of the LP problem - - Parameters - ------------- - sol - Solution of the ILP problem by the given algorithm - parameters - Possible parameters of the algorithm - - Returns - ------------- - prim_obj - Primal objective - """ - return sol["primal objective"] - - -def get_points_from_sol(sol, parameters=None): - """ - Gets the points from the solution - - Parameters - ------------- - sol - Solution of the LP problem by the given algorithm - parameters - Possible parameters of the algorithm - - Returns - ------------- - points - Point of the solution - """ - if parameters is None: - parameters = {} - - maximize = parameters["maximize"] if "maximize" in parameters else False - return_when_none = parameters["return_when_none"] if "return_when_none" in parameters else False - var_corr = parameters["var_corr"] if "var_corr" in parameters else {} - - if sol and 'x' in sol and sol['x'] is not None: - return list(sol['x']) - else: - if return_when_none: - if maximize: - return [sys.float_info.max] * len(list(var_corr.keys())) - return [sys.float_info.min] * len(list(var_corr.keys()))