diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9f423d02..5c3631c5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -68,7 +68,7 @@ jobs: pytest spopt \ -v \ -r a \ - -n logical \ + -n 1 \ --color yes \ --cov spopt \ --cov-append \ diff --git a/ci/py311_spopt-latest.yaml b/ci/py311_spopt-latest.yaml index d1bb72db..d8ee0cd6 100644 --- a/ci/py311_spopt-latest.yaml +++ b/ci/py311_spopt-latest.yaml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - python=3.11 + - coin-or-cbc - fast_hdbscan # for sa3 - geopandas - libpysal @@ -12,6 +13,7 @@ dependencies: - numpy - pandas - pointpats + - pulp - scikit-learn - scipy - shapely @@ -23,9 +25,4 @@ dependencies: - coverage - pytest - pytest-cov - - pytest-xdist - - # with pip - - pip - - pip: - - pulp + - pytest-xdist \ No newline at end of file diff --git a/ci/py311_spopt-oldest.yaml b/ci/py311_spopt-oldest.yaml index 112d4591..6347cfc9 100644 --- a/ci/py311_spopt-oldest.yaml +++ b/ci/py311_spopt-oldest.yaml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - python=3.11 + - coin-or-cbc - fast_hdbscan=0.2.2 # for sa3 - fiona<1.10 # see gh#492 - geopandas=0.14.0 @@ -13,6 +14,7 @@ dependencies: - numpy=1.26.0 - pandas=2.1.0 - pointpats=2.4.0 + - pulp=2.8 - scikit-learn=1.4.0 - scipy=1.12.0 - shapely=2.1.0 @@ -25,8 +27,3 @@ dependencies: - pytest - pytest-cov - pytest-xdist - - # with pip - - pip - - pip: - - pulp==2.8 diff --git a/ci/py312_spopt-latest.yaml b/ci/py312_spopt-latest.yaml index b9d4bbce..09ef75c5 100644 --- a/ci/py312_spopt-latest.yaml +++ b/ci/py312_spopt-latest.yaml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - python=3.12 + - coin-or-cbc - fast_hdbscan # for sa3 - geopandas - libpysal @@ -12,6 +13,7 @@ dependencies: - numpy - pandas - pointpats + - pulp - scikit-learn - scipy - shapely @@ -24,8 +26,3 @@ dependencies: - pytest - pytest-cov - pytest-xdist - - # with pip - - pip - - pip: - - pulp diff --git a/ci/py313_spopt-dev.yaml b/ci/py313_spopt-dev.yaml index 18c463b8..f3c62bda 100644 --- a/ci/py313_spopt-dev.yaml +++ b/ci/py313_spopt-dev.yaml @@ -3,9 +3,11 @@ channels: - conda-forge dependencies: - python=3.13 + - coin-or-cbc - fast_hdbscan # for sa3 - folium # for geopandas.explore() - matplotlib # for geopandas.explore() + - pulp - numba # for sa3 - tqdm @@ -26,7 +28,6 @@ dependencies: - networkx - numpy - pandas - - pulp - scikit-learn - scipy - shapely diff --git a/ci/py313_spopt-latest.yaml b/ci/py313_spopt-latest.yaml index 860ce392..966be054 100644 --- a/ci/py313_spopt-latest.yaml +++ b/ci/py313_spopt-latest.yaml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - python=3.13 + - coin-or-cbc - fast_hdbscan # for sa3 - geopandas - libpysal @@ -12,6 +13,7 @@ dependencies: - numpy - pandas - pointpats + - pulp - scikit-learn - scipy - shapely @@ -32,8 +34,3 @@ dependencies: - sphinxcontrib-bibtex - sphinx_bootstrap_theme - # with pip - - pip - - pip: - - pulp - diff --git a/environment.yml b/environment.yml index 23adc9ad..ddee642d 100644 --- a/environment.yml +++ b/environment.yml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - python=3.13 + - coin-or-cbc - fast_hdbscan - geopandas - jupyterlab @@ -35,5 +36,4 @@ dependencies: - pip: - git+https://github.com/pysal/spopt.git@main # (notebook/binder specific) having trouble resolving routingpy via conda-forge - - routingpy - - pulp + - routingpy \ No newline at end of file diff --git a/spopt/tests/test_locate/test_c_p_median.py b/spopt/tests/test_locate/test_c_p_median.py index e9520fd2..00e40ba6 100644 --- a/spopt/tests/test_locate/test_c_p_median.py +++ b/spopt/tests/test_locate/test_c_p_median.py @@ -25,7 +25,7 @@ def test_c_p_median_from_cost_matrix(self): p_facilities=2, facility_capacities=facility_capacity, ) - result = p_median.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_median.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PMedian) known = [[1], [2]] @@ -48,7 +48,7 @@ def test_c_p_median_with_predefined_facilities_from_cost_matrix(self): predefined_facilities_arr=predefine, fulfill_predefined_fac=True, ) - result = p_median.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_median.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PMedian) known = [[1], [2]] @@ -74,7 +74,7 @@ def test_c_p_median_with_predefined_facilities_infeasible( fulfill_predefined_fac=True, ) with loc_raises_infeasible: - p_median.solve(pulp.PULP_CBC_CMD(msg=False)) + p_median.solve(pulp.COIN_CMD(msg=False)) class TestRealWorldLocate: @@ -116,7 +116,7 @@ def test_optimality_capacitated_pmedian_with_predefined_facilities(self): facility_capacities=self.capacities_arr, fulfill_predefined_fac=True, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) assert pmedian.problem.status == pulp.LpStatusOptimal def test_infeasibility_capacitated_pmedian(self, loc_raises_infeasible): @@ -124,7 +124,7 @@ def test_infeasibility_capacitated_pmedian(self, loc_raises_infeasible): self.cost_matrix, self.demand, 0, facility_capacities=self.capacities_arr ) with loc_raises_infeasible: - pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian.solve(pulp.COIN_CMD(msg=False)) def test_mixin_mean_time(self): mean_time_expected = 87.2 @@ -136,7 +136,7 @@ def test_mixin_mean_time(self): facility_capacities=self.capacities_arr, fulfill_predefined_fac=True, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) assert pmedian.mean_dist == mean_time_expected def test_infeasibility_predefined_facilities_fulfillment_error(self): diff --git a/spopt/tests/test_locate/test_clscp-so.py b/spopt/tests/test_locate/test_clscp-so.py index 1481ace8..2f90aa7b 100644 --- a/spopt/tests/test_locate/test_clscp-so.py +++ b/spopt/tests/test_locate/test_clscp-so.py @@ -26,7 +26,7 @@ def test_clscpso_y1_lt_y2(self): facility_capacity_arr=facility_capacity, demand_quantity_arr=demand_quantity, ) - result = clscpso.solve(pulp.PULP_CBC_CMD(msg=False)) + result = clscpso.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, LSCP) known = [[1], [1], [1], [1], [1]] @@ -47,7 +47,7 @@ def test_clscpso_y1_gt_y2(self): facility_capacity_arr=facility_capacity, demand_quantity_arr=demand_quantity, ) - result = clscpso.solve(pulp.PULP_CBC_CMD(msg=False)) + result = clscpso.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, LSCP) known = [[1], [1], [0, 1], [0, 1], [0, 1]] @@ -68,7 +68,7 @@ def test_clscpso_y1_eq_y2(self): facility_capacity_arr=facility_capacity, demand_quantity_arr=demand_quantity, ) - result = clscpso.solve(pulp.PULP_CBC_CMD(msg=False)) + result = clscpso.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, LSCP) known = [[1], [1], [0, 1], [0], [1]] @@ -104,4 +104,4 @@ def test_clscpso_infease_error(self, loc_raises_infeasible): demand_quantity_arr=demand_quantity, ) with loc_raises_infeasible: - clscpso.solve(pulp.PULP_CBC_CMD(msg=False)) + clscpso.solve(pulp.COIN_CMD(msg=False)) diff --git a/spopt/tests/test_locate/test_flow.py b/spopt/tests/test_locate/test_flow.py index 84cfa603..30942576 100644 --- a/spopt/tests/test_locate/test_flow.py +++ b/spopt/tests/test_locate/test_flow.py @@ -48,7 +48,7 @@ def test_vehicle_range_percentage(self, setup_simple_network): ) assert model.vehicle_range == 30 - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" assert len(model.selected_facilities) == 3 coverage = model.get_flow_coverage() @@ -66,7 +66,7 @@ def test_ac_pc_approach(self, setup_grid_network): assert model.k is not None assert model.a is not None - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" def test_combination_approach(self, setup_grid_network): @@ -79,7 +79,7 @@ def test_combination_approach(self, setup_grid_network): assert model.path_refueling_combinations is not None - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" @@ -106,7 +106,7 @@ def test_flow_objective(self, setup_network_with_distances): vehicle_range=50, objective="flow", ) - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" coverage = model.get_flow_coverage() assert coverage["covered_volume"] == 50 @@ -122,7 +122,7 @@ def test_vmt_objective(self, setup_network_with_distances): objective="vmt", ) - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" vmt_coverage = model.get_vmt_coverage() assert "total_vmt" in vmt_coverage @@ -147,7 +147,7 @@ def test_threshold_basic(self, setup_threshold_network): threshold=0.8, weight=0.5, ) - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" model.calculate_covered_nodes() for node in model.covered_nodes: @@ -173,7 +173,7 @@ def test_threshold_weight_impact(self, setup_threshold_network): threshold=0.8, weight=0.99, ) - result_high = model_high_weight.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result_high = model_high_weight.solve(solver=pulp.COIN_CMD(msg=0)) model_low_weight = FRLM.from_flow_dataframe( network=network, @@ -183,7 +183,7 @@ def test_threshold_weight_impact(self, setup_threshold_network): threshold=0.8, weight=0.01, ) - result_low = model_low_weight.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result_low = model_low_weight.solve(solver=pulp.COIN_CMD(msg=0)) assert result_high["status"] == "Optimal" assert result_low["status"] == "Optimal" @@ -352,7 +352,7 @@ def setup_solved_model(self): network=network, flows=simple_flows, p_facilities=2, vehicle_range=25 ) - model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + model.solve(solver=pulp.COIN_CMD(msg=0)) return model def test_summary_output(self, setup_solved_model): @@ -458,7 +458,7 @@ def test_custom_paths_basic(self): assert model.flow_paths[(0, 15)] == [0, 4, 8, 12, 13, 14, 15] - result = model.solve(solver=pulp.PULP_CBC_CMD(msg=0)) + result = model.solve(solver=pulp.COIN_CMD(msg=0)) assert result["status"] == "Optimal" def test_invalid_custom_paths(self): diff --git a/spopt/tests/test_locate/test_knearest_p_median.py b/spopt/tests/test_locate/test_knearest_p_median.py index dc8747e7..56562665 100644 --- a/spopt/tests/test_locate/test_knearest_p_median.py +++ b/spopt/tests/test_locate/test_knearest_p_median.py @@ -36,7 +36,7 @@ def setup_method(self) -> None: facility_capacity_col="capacity", k_array=k, ) - self.solver = pulp.PULP_CBC_CMD(msg=False) + self.solver = pulp.COIN_CMD(msg=False) def test_knearest_p_median_from_geodataframe(self): result = self.k_nearest_pmedian.solve(self.solver) diff --git a/spopt/tests/test_locate/test_lscp.py b/spopt/tests/test_locate/test_lscp.py index 7548b770..7419f067 100644 --- a/spopt/tests/test_locate/test_lscp.py +++ b/spopt/tests/test_locate/test_lscp.py @@ -19,12 +19,12 @@ def setup_method(self, network_instance) -> None: def test_lscp_from_cost_matrix(self): lscp = LSCP.from_cost_matrix(self.cost_matrix, 10) - result = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + result = lscp.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, LSCP) def test_lscp_from_cost_matrix_no_results(self): lscp = LSCP.from_cost_matrix(self.cost_matrix, 10) - result = lscp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + result = lscp.solve(pulp.COIN_CMD(msg=False), results=False) assert isinstance(result, LSCP) with pytest.raises(AttributeError): @@ -36,7 +36,7 @@ def test_lscp_facility_client_array_from_cost_matrix(self, load_locate_test_data lscp_objective = load_locate_test_data("lscp_fac2cli.pkl") lscp = LSCP.from_cost_matrix(self.cost_matrix, 8) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(lscp.fac2cli, dtype=object), @@ -47,7 +47,7 @@ def test_lscp_client_facility_array_from_cost_matrix(self, load_locate_test_data lscp_objective = load_locate_test_data("lscp_cli2fac.pkl") lscp = LSCP.from_cost_matrix(self.cost_matrix, 8) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(lscp.cli2fac, dtype=object), @@ -58,7 +58,7 @@ def test_lscp_from_geodataframe(self): lscp = LSCP.from_geodataframe( self.clients_snapped, self.facilities_snapped, "geometry", "geometry", 10 ) - result = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + result = lscp.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, LSCP) def test_lscp_facility_client_array_from_geodataframe(self, load_locate_test_data): @@ -71,7 +71,7 @@ def test_lscp_facility_client_array_from_geodataframe(self, load_locate_test_dat "geometry", 8, ) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(lscp.fac2cli, dtype=object), @@ -88,7 +88,7 @@ def test_lscp_client_facility_array_from_geodataframe(self, load_locate_test_dat "geometry", 8, ) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(lscp.cli2fac, dtype=object), @@ -114,7 +114,7 @@ def test_lscp_preselected_facility_client_array_from_geodataframe( predefined_facility_col="predefined_loc", service_radius=8, ) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False, warmStart=True)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False, warmStart=True)) numpy.testing.assert_array_equal( numpy.array(lscp.fac2cli, dtype=object), @@ -168,14 +168,14 @@ def setup_method(self, load_locate_test_data) -> None: def test_optimality_lscp_from_cost_matrix(self): lscp = LSCP.from_cost_matrix(self.cost_matrix, self.service_dist) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) assert lscp.problem.status == pulp.LpStatusOptimal def test_infeasibility_lscp_from_cost_matrix(self, loc_raises_infeasible): lscp = LSCP.from_cost_matrix(self.cost_matrix, 20) with loc_raises_infeasible: - lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp.solve(pulp.COIN_CMD(msg=False)) def test_optimality_lscp_from_geodataframe(self): lscp = LSCP.from_geodataframe( @@ -185,7 +185,7 @@ def test_optimality_lscp_from_geodataframe(self): "geometry", self.service_dist, ) - lscp = lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp = lscp.solve(pulp.COIN_CMD(msg=False)) assert lscp.problem.status == pulp.LpStatusOptimal def test_infeasibility_lscp_from_geodataframe(self, loc_raises_infeasible): @@ -197,7 +197,7 @@ def test_infeasibility_lscp_from_geodataframe(self, loc_raises_infeasible): 0, ) with loc_raises_infeasible: - lscp.solve(pulp.PULP_CBC_CMD(msg=False)) + lscp.solve(pulp.COIN_CMD(msg=False)) class TestErrorsWarnings: diff --git a/spopt/tests/test_locate/test_lscpb.py b/spopt/tests/test_locate/test_lscpb.py index 7c99db17..b8f193d9 100644 --- a/spopt/tests/test_locate/test_lscpb.py +++ b/spopt/tests/test_locate/test_lscpb.py @@ -22,17 +22,13 @@ def setup_method(self, network_instance) -> None: self.clients_snapped["weights"] = self.ai def test_lscpb_from_cost_matrix(self): - lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, 10, pulp.PULP_CBC_CMD(msg=False) - ) + lscpb = LSCPB.from_cost_matrix(self.cost_matrix, 10, pulp.COIN_CMD(msg=False)) result = lscpb.solve() assert isinstance(result, LSCPB) def test_lscpb_from_cost_matrix_no_results(self): - lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, 10, pulp.PULP_CBC_CMD(msg=False) - ) + lscpb = LSCPB.from_cost_matrix(self.cost_matrix, 10, pulp.COIN_CMD(msg=False)) result = lscpb.solve(results=False) assert isinstance(result, LSCPB) @@ -46,9 +42,7 @@ def test_lscpb_from_cost_matrix_no_results(self): def test_lscpb_facility_client_array_from_cost_matrix(self, load_locate_test_data): lscpb_objective = load_locate_test_data("lscpb_fac2cli.pkl") - lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, 8, pulp.PULP_CBC_CMD(msg=False) - ) + lscpb = LSCPB.from_cost_matrix(self.cost_matrix, 8, pulp.COIN_CMD(msg=False)) lscpb = lscpb.solve() numpy.testing.assert_array_equal( @@ -59,9 +53,7 @@ def test_lscpb_facility_client_array_from_cost_matrix(self, load_locate_test_dat def test_lscpb_client_facility_array_from_cost_matrix(self, load_locate_test_data): lscpb_objective = load_locate_test_data("lscpb_cli2fac.pkl") - lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, 8, pulp.PULP_CBC_CMD(msg=False) - ) + lscpb = LSCPB.from_cost_matrix(self.cost_matrix, 8, pulp.COIN_CMD(msg=False)) lscpb = lscpb.solve() numpy.testing.assert_array_equal( @@ -76,7 +68,7 @@ def test_lscpb_from_geodataframe(self): "geometry", "geometry", 10, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) result = lscpb.solve() @@ -91,7 +83,7 @@ def test_lscpb_facility_client_array_from_geodataframe(self, load_locate_test_da "geometry", "geometry", 8, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) lscpb = lscpb.solve() @@ -109,7 +101,7 @@ def test_lscpb_client_facility_array_from_geodataframe(self, load_locate_test_da "geometry", "geometry", 8, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) lscpb = lscpb.solve() @@ -134,7 +126,7 @@ def test_lscpb_preselected_facility_client_array_from_geodataframe( "geometry", "geometry", 8, - pulp.PULP_CBC_CMD(msg=False, warmStart=True), + pulp.COIN_CMD(msg=False, warmStart=True), predefined_facility_col="predefined_loc", ) lscpb = lscpb.solve() @@ -191,7 +183,7 @@ def setup_method(self, load_locate_test_data) -> None: def test_optimality_lscpb_from_cost_matrix(self): lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, self.service_dist, pulp.PULP_CBC_CMD(msg=False) + self.cost_matrix, self.service_dist, pulp.COIN_CMD(msg=False) ) lscpb = lscpb.solve() @@ -200,14 +192,14 @@ def test_optimality_lscpb_from_cost_matrix(self): def test_infeasibility_lscpb_from_cost_matrix(self, loc_raises_infeasible): with loc_raises_infeasible: lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, 20, pulp.PULP_CBC_CMD(msg=False) + self.cost_matrix, 20, pulp.COIN_CMD(msg=False) ) lscpb.solve() def test_mixin_lscpb_get_percentage(self): percentage_expected = 81.46341463414633 lscpb = LSCPB.from_cost_matrix( - self.cost_matrix, self.service_dist, pulp.PULP_CBC_CMD(msg=False) + self.cost_matrix, self.service_dist, pulp.COIN_CMD(msg=False) ) lscpb = lscpb.solve() @@ -220,7 +212,7 @@ def test_optimality_lscpb_from_geodataframe(self): "geometry", "geometry", self.service_dist, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) lscpb = lscpb.solve() @@ -234,7 +226,7 @@ def test_infeasibility_lscpb_from_geodataframe(self, loc_raises_infeasible): "geometry", "geometry", 0, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) lscpb.solve() @@ -259,7 +251,7 @@ def test_error_lscpb_different_crs( "geometry", "geometry", 10, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) def test_warning_lscpb_demand_geodataframe( @@ -272,13 +264,13 @@ def test_warning_lscpb_demand_geodataframe( "geometry", "geometry", 100, - pulp.PULP_CBC_CMD(msg=False), + pulp.COIN_CMD(msg=False), ) def test_attribute_error_add_backup_covering_constraint(self): with pytest.raises(AttributeError, match="Before setting backup coverage"): dummy_class = LSCPB( - "dummy", pulp.LpProblem("name"), pulp.PULP_CBC_CMD(msg=False) + "dummy", pulp.LpProblem("name"), pulp.COIN_CMD(msg=False) ) dummy_fac_r = 0 dummy_cli_r = 0 diff --git a/spopt/tests/test_locate/test_mclp.py b/spopt/tests/test_locate/test_mclp.py index 65062f07..3d8a0adb 100644 --- a/spopt/tests/test_locate/test_mclp.py +++ b/spopt/tests/test_locate/test_mclp.py @@ -25,7 +25,7 @@ def test_mclp_from_cost_matrix(self): mclp = MCLP.from_cost_matrix( self.cost_matrix, self.ai, service_radius=7, p_facilities=4 ) - result = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=True) + result = mclp.solve(pulp.COIN_CMD(msg=False), results=True) assert isinstance(result, MCLP) assert result.n_cli_uncov == 1 @@ -35,7 +35,7 @@ def test_mclp_from_cost_matrix_no_results(self): mclp = MCLP.from_cost_matrix( self.cost_matrix, self.ai, service_radius=7, p_facilities=4 ) - result = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + result = mclp.solve(pulp.COIN_CMD(msg=False), results=False) assert isinstance(result, MCLP) @@ -57,7 +57,7 @@ def test_mclp_facility_client_array_from_cost_matrix(self, load_locate_test_data service_radius=7, p_facilities=4, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(mclp.fac2cli, dtype=object), @@ -73,7 +73,7 @@ def test_mclp_client_facility_array_from_cost_matrix(self, load_locate_test_data service_radius=7, p_facilities=4, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(mclp.cli2fac, dtype=object), @@ -90,7 +90,7 @@ def test_mclp_from_geodataframe(self): service_radius=7, p_facilities=4, ) - result = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + result = mclp.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, MCLP) def test_mclp_facility_client_array_from_geodataframe(self, load_locate_test_data): @@ -105,7 +105,7 @@ def test_mclp_facility_client_array_from_geodataframe(self, load_locate_test_dat service_radius=7, p_facilities=4, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(mclp.fac2cli, dtype=object), @@ -133,7 +133,7 @@ def test_mclp_preselected_facility_client_array_from_geodataframe( service_radius=7, p_facilities=4, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False, warmStart=True)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False, warmStart=True)) numpy.testing.assert_array_equal( numpy.array(mclp.fac2cli, dtype=object), @@ -152,7 +152,7 @@ def test_mclp_client_facility_array_from_geodataframe(self, load_locate_test_dat service_radius=7, p_facilities=4, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(mclp.cli2fac, dtype=object), @@ -211,7 +211,7 @@ def test_optimality_mclp_from_cost_matrix(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) assert mclp.problem.status == pulp.LpStatusOptimal def test_infeasibility_mclp_from_cost_matrix(self, loc_raises_infeasible): @@ -222,7 +222,7 @@ def test_infeasibility_mclp_from_cost_matrix(self, loc_raises_infeasible): 1000, ) with loc_raises_infeasible: - mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp.solve(pulp.COIN_CMD(msg=False)) def test_mixin_mclp_get_uncovered_clients(self): uncovered_clients_expected = 21 @@ -232,7 +232,7 @@ def test_mixin_mclp_get_uncovered_clients(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) assert mclp.n_cli_uncov == uncovered_clients_expected @@ -244,7 +244,7 @@ def test_mixin_mclp_get_percentage(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) assert mclp.perc_cov == pytest.approx(percentage_expected) @@ -258,7 +258,7 @@ def test_optimality_mclp_from_geodataframe(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp = mclp.solve(pulp.COIN_CMD(msg=False)) assert mclp.problem.status == pulp.LpStatusOptimal def test_infeasibility_mclp_from_geodataframe(self, loc_raises_infeasible): @@ -272,7 +272,7 @@ def test_infeasibility_mclp_from_geodataframe(self, loc_raises_infeasible): 1000, ) with loc_raises_infeasible: - mclp.solve(pulp.PULP_CBC_CMD(msg=False)) + mclp.solve(pulp.COIN_CMD(msg=False)) def test_attribute_error_fac2cli_mclp_facility_client_array(self): mclp = MCLP.from_geodataframe( @@ -284,7 +284,7 @@ def test_attribute_error_fac2cli_mclp_facility_client_array(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + mclp = mclp.solve(pulp.COIN_CMD(msg=False), results=False) with pytest.raises( AttributeError, match="'MCLP' object has no attribute 'fac2cli'" @@ -301,7 +301,7 @@ def test_attribute_error_cli2fac_mclp_facility_client_array(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + mclp = mclp.solve(pulp.COIN_CMD(msg=False), results=False) with pytest.raises( AttributeError, match="'MCLP' object has no attribute 'cli2fac'" @@ -318,7 +318,7 @@ def test_attribute_error_ncliuncov_mclp_facility_client_array(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + mclp = mclp.solve(pulp.COIN_CMD(msg=False), results=False) with pytest.raises( AttributeError, match="'MCLP' object has no attribute 'n_cli_uncov'" @@ -335,7 +335,7 @@ def test_attribute_error_percentage_mclp_facility_client_array(self): self.service_dist, self.p_facility, ) - mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + mclp = mclp.solve(pulp.COIN_CMD(msg=False), results=False) with pytest.raises( AttributeError, match="The attribute `n_cli_uncov` is not set." diff --git a/spopt/tests/test_locate/test_p_center.py b/spopt/tests/test_locate/test_p_center.py index ea08e836..7b3719cc 100644 --- a/spopt/tests/test_locate/test_p_center.py +++ b/spopt/tests/test_locate/test_p_center.py @@ -19,12 +19,12 @@ def setup_method(self, network_instance) -> None: def test_p_center_from_cost_matrix(self): p_center = PCenter.from_cost_matrix(self.cost_matrix, p_facilities=4) - result = p_center.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_center.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PCenter) def test_p_center_from_cost_matrix_no_results(self): p_center = PCenter.from_cost_matrix(self.cost_matrix, p_facilities=4) - result = p_center.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + result = p_center.solve(pulp.COIN_CMD(msg=False), results=False) assert isinstance(result, PCenter) with pytest.raises(AttributeError): @@ -38,7 +38,7 @@ def test_pcenter_facility_client_array_from_cost_matrix( pcenter_objective = load_locate_test_data("pcenter_fac2cli.pkl") pcenter = PCenter.from_cost_matrix(self.cost_matrix, p_facilities=4) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pcenter.fac2cli, dtype=object), @@ -53,7 +53,7 @@ def test_p_center_from_geodataframe(self): "geometry", p_facilities=4, ) - result = p_center.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_center.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PCenter) def test_pcenter_facility_client_array_from_geodataframe( @@ -68,7 +68,7 @@ def test_pcenter_facility_client_array_from_geodataframe( "geometry", p_facilities=4, ) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pcenter.fac2cli, dtype=object), @@ -87,7 +87,7 @@ def test_pcenter_client_facility_array_from_geodataframe( "geometry", 4, ) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pcenter.cli2fac, dtype=object), @@ -109,7 +109,7 @@ def test_pcenter_preselected_facility_client_array_from_geodataframe(self): 3, predefined_facility_col="predefined_loc", ) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False, warmStart=True)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False, warmStart=True)) observed_objval = pcenter.problem.objective.value() assert known_objval == pytest.approx(observed_objval) @@ -167,13 +167,13 @@ def setup_method(self, load_locate_test_data) -> None: def test_optimality_pcenter_from_cost_matrix(self): pcenter = PCenter.from_cost_matrix(self.cost_matrix, self.p_facility) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False)) assert pcenter.problem.status == pulp.LpStatusOptimal def test_infeasibility_pcenter_from_cost_matrix(self, loc_raises_infeasible): pcenter = PCenter.from_cost_matrix(self.cost_matrix, 0) with loc_raises_infeasible: - pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter.solve(pulp.COIN_CMD(msg=False)) def test_optimality_pcenter_from_geodataframe(self): pcenter = PCenter.from_geodataframe( @@ -183,7 +183,7 @@ def test_optimality_pcenter_from_geodataframe(self): "geometry", self.p_facility, ) - pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter = pcenter.solve(pulp.COIN_CMD(msg=False)) assert pcenter.problem.status == pulp.LpStatusOptimal def test_infeasibility_pcenter_from_geodataframe(self, loc_raises_infeasible): @@ -195,7 +195,7 @@ def test_infeasibility_pcenter_from_geodataframe(self, loc_raises_infeasible): 0, ) with loc_raises_infeasible: - pcenter.solve(pulp.PULP_CBC_CMD(msg=False)) + pcenter.solve(pulp.COIN_CMD(msg=False)) class TestErrorsWarnings: diff --git a/spopt/tests/test_locate/test_p_dispersion.py b/spopt/tests/test_locate/test_p_dispersion.py index 00241978..570b50d4 100644 --- a/spopt/tests/test_locate/test_p_dispersion.py +++ b/spopt/tests/test_locate/test_p_dispersion.py @@ -17,12 +17,12 @@ def setup_method(self, network_instance) -> None: def test_p_dispersion_from_cost_matrix(self): pdispersion = PDispersion.from_cost_matrix(self.cost_matrix, 2) - result = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + result = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PDispersion) def test_p_dispersion_from_cost_matrix_no_results(self): pdispersion = PDispersion.from_cost_matrix(self.cost_matrix, 2) - result = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + result = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PDispersion) with pytest.raises(AttributeError): @@ -36,7 +36,7 @@ def test_p_dispersion_from_geodataframe(self): "geometry", 2, ) - result = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + result = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PDispersion) def test_p_dispersion_preselected_facility_array_from_geodataframe(self): @@ -52,7 +52,7 @@ def test_p_dispersion_preselected_facility_array_from_geodataframe(self): 3, predefined_facility_col="predefined_loc", ) - result = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + result = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PDispersion) observed_objval = pdispersion.problem.objective.value() @@ -98,7 +98,7 @@ def setup_method(self, load_locate_test_data) -> None: def test_optimality_p_dispersion_from_cost_matrix(self): pdispersion = PDispersion.from_cost_matrix(self.cost_matrix, self.p_facility) - pdispersion = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + pdispersion = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert pdispersion.problem.status == pulp.LpStatusOptimal known_solution_set = ["y_0_", "y_1_", "y_14_", "y_15_"] @@ -110,7 +110,7 @@ def test_optimality_p_dispersion_from_cost_matrix(self): def test_infeasibility_p_dispersion_from_cost_matrix(self, loc_raises_infeasible): pdispersion = PDispersion.from_cost_matrix(self.cost_matrix, 17) with loc_raises_infeasible: - pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + pdispersion.solve(pulp.COIN_CMD(msg=False)) def test_optimality_p_dispersion_from_geodataframe(self): pdispersion = PDispersion.from_geodataframe( @@ -118,7 +118,7 @@ def test_optimality_p_dispersion_from_geodataframe(self): "geometry", self.p_facility, ) - pdispersion = pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + pdispersion = pdispersion.solve(pulp.COIN_CMD(msg=False)) assert pdispersion.problem.status == pulp.LpStatusOptimal known_solution_set = ["y_0_", "y_2_", "y_8_", "y_14_"] @@ -134,7 +134,7 @@ def test_infeasibility_p_dispersion_from_geodataframe(self, loc_raises_infeasibl 17, ) with loc_raises_infeasible: - pdispersion.solve(pulp.PULP_CBC_CMD(msg=False)) + pdispersion.solve(pulp.COIN_CMD(msg=False)) class TestErrorsWarnings: diff --git a/spopt/tests/test_locate/test_p_median.py b/spopt/tests/test_locate/test_p_median.py index f0dfb7cc..159a3bed 100644 --- a/spopt/tests/test_locate/test_p_median.py +++ b/spopt/tests/test_locate/test_p_median.py @@ -23,12 +23,12 @@ def setup_method(self, network_instance) -> None: def test_p_median_from_cost_matrix(self): p_median = PMedian.from_cost_matrix(self.cost_matrix, self.ai, p_facilities=4) - result = p_median.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_median.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PMedian) def test_p_median_from_cost_matrix_no_results(self): p_median = PMedian.from_cost_matrix(self.cost_matrix, self.ai, p_facilities=4) - result = p_median.solve(pulp.PULP_CBC_CMD(msg=False), results=False) + result = p_median.solve(pulp.COIN_CMD(msg=False), results=False) assert isinstance(result, PMedian) with pytest.raises(AttributeError): @@ -44,7 +44,7 @@ def test_pmedian_facility_client_array_from_cost_matrix( pmedian_objective = load_locate_test_data("pmedian_fac2cli.pkl") pmedian = PMedian.from_cost_matrix(self.cost_matrix, self.ai, p_facilities=4) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pmedian.fac2cli, dtype=object), @@ -57,7 +57,7 @@ def test_pmedian_client_facility_array_from_cost_matrix( pmedian_objective = load_locate_test_data("pmedian_cli2fac.pkl") pmedian = PMedian.from_cost_matrix(self.cost_matrix, self.ai, p_facilities=4) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pmedian.cli2fac, dtype=object), @@ -73,7 +73,7 @@ def test_p_median_from_geodataframe(self): "weights", p_facilities=4, ) - result = p_median.solve(pulp.PULP_CBC_CMD(msg=False)) + result = p_median.solve(pulp.COIN_CMD(msg=False)) assert isinstance(result, PMedian) def test_pmedian_facility_client_array_from_geodataframe( @@ -89,7 +89,7 @@ def test_pmedian_facility_client_array_from_geodataframe( "weights", p_facilities=4, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pmedian.fac2cli, dtype=object), @@ -109,7 +109,7 @@ def test_pmedian_client_facility_array_from_geodataframe( "weights", p_facilities=4, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) numpy.testing.assert_array_equal( numpy.array(pmedian.cli2fac, dtype=object), @@ -133,7 +133,7 @@ def test_pmedian_preselected_facility_client_array_from_geodataframe(self): predefined_facility_col="predefined_loc", p_facilities=3, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False, warmStart=True)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False, warmStart=True)) observed_objval = pmedian.problem.objective.value() assert known_objval == pytest.approx(observed_objval) @@ -194,18 +194,18 @@ def setup_method(self, load_locate_test_data) -> None: def test_optimality_pmedian_from_cost_matrix(self): pmedian = PMedian.from_cost_matrix(self.cost_matrix, self.ai, self.p_facility) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) assert pmedian.problem.status == pulp.LpStatusOptimal def test_infeasibility_pmedian_from_cost_matrix(self, loc_raises_infeasible): pmedian = PMedian.from_cost_matrix(self.cost_matrix, self.ai, 0) with loc_raises_infeasible: - pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian.solve(pulp.COIN_CMD(msg=False)) def test_mixin_mean_distance(self): mean_distance_expected = 2982.1268579890657 pmedian = PMedian.from_cost_matrix(self.cost_matrix, self.ai, self.p_facility) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) assert pmedian.mean_dist == mean_distance_expected @@ -218,7 +218,7 @@ def test_optimality_pmedian_from_geodataframe(self): "POP2000", self.p_facility, ) - pmedian = pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian = pmedian.solve(pulp.COIN_CMD(msg=False)) assert pmedian.problem.status == pulp.LpStatusOptimal def test_infeasibility_pmedian_from_geodataframe(self, loc_raises_infeasible): @@ -231,7 +231,7 @@ def test_infeasibility_pmedian_from_geodataframe(self, loc_raises_infeasible): 0, ) with loc_raises_infeasible: - pmedian.solve(pulp.PULP_CBC_CMD(msg=False)) + pmedian.solve(pulp.COIN_CMD(msg=False)) class TestErrorsWarnings: