Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

investigate failures dependent on variable names #295

Open
jGaboardi opened this issue Oct 31, 2022 · 0 comments
Open

investigate failures dependent on variable names #295

jGaboardi opened this issue Oct 31, 2022 · 0 comments

Comments

@jGaboardi
Copy link
Member

Assigning decision variables different named labels should not alter the results of an optimization problem, but this seems to be happening. For example, tests fail when the client decision variable is renamed "x[{i}_{j}]" from "z[{i}_{j}]" when building p-center problem.

  • PCenter failures
    [gw3] darwin -- Python 3.10.6 /Users/user/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x1635b4b50>
    
        def test_pcenter_facility_client_array_from_cost_matrix(self):
            with open(self.dirpath + "pcenter_fac2cli.pkl", "rb") as f:
                pcenter_objective = pickle.load(f)
        
            pcenter = PCenter.from_cost_matrix(self.cost_matrix, p_facilities=4)
            pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(pcenter.fac2cli, dtype=object),
                numpy.array(pcenter_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 4 / 5 (80%)
    E        x: array([list([5, 18, 19, 22, 25, 28, 32, 47, 48, 62, 65, 68, 72]),
    E              list([0, 1, 9, 10, 12, 13, 15, 17, 20, 21, 29, 43, 44, 46, 50, 57, 59, 60, 69, 73, 74, 75, 79, 81, 84, 86, 91, 92, 94, 95, 99]),
    E              list([2, 3, 4, 6, 7, 8, 23, 26, 31, 33, 34, 35, 37, 49, 52, 54, 58, 61, 63, 66, 70, 78, 80, 82, 89, 90, 93, 96, 97]),...
    E        y: array([list([5, 18, 19, 22, 28, 32, 34, 36, 48, 53, 62, 68, 72, 90, 96]),
    E              list([0, 10, 12, 13, 15, 17, 20, 21, 29, 37, 46, 50, 60, 64, 73, 75, 79, 81, 84, 86, 91, 92, 94, 99]),
    E              list([2, 3, 4, 6, 7, 8, 23, 25, 26, 31, 33, 35, 43, 44, 47, 49, 52, 54, 57, 58, 59, 65, 66, 69, 70, 74, 78, 80, 82, 89, 93, 95, 97]),...
    
    spopt/tests/test_locate.py:398: AssertionError
    ___________________________________________ TestSyntheticLocate.test_pcenter_client_facility_array_from_cost_matrix ___________________________________________
    [gw0] darwin -- Python 3.10.6 /Users/user/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x165ac0a90>
    
        def test_pcenter_client_facility_array_from_cost_matrix(self):
            with open(self.dirpath + "pcenter_cli2fac.pkl", "rb") as f:
                pcenter_objective = pickle.load(f)
        
            pcenter = PCenter.from_cost_matrix(self.cost_matrix, p_facilities=4)
            pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(pcenter.cli2fac, dtype=object),
                numpy.array(pcenter_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 21 / 100 (21%)
    E       Max absolute difference: 4
    E       Max relative difference: 3.0
    E        x: array([[1],
    E              [1],
    E              [2],...
    E        y: array([[1],
    E              [4],
    E              [2],...
    
    spopt/tests/test_locate.py:410: AssertionError
    __________________________________________ TestSyntheticLocate.test_pcenter_facility_client_array_from_geodataframe ___________________________________________
    [gw2] darwin -- Python 3.10.6 /Users/user/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x173404f10>
    
        def test_pcenter_facility_client_array_from_geodataframe(self):
            with open(self.dirpath + "pcenter_geodataframe_fac2cli.pkl", "rb") as f:
                pcenter_objective = pickle.load(f)
        
            pcenter = PCenter.from_geodataframe(
                self.clients_snapped,
                self.facilities_snapped,
                "geometry",
                "geometry",
                p_facilities=4,
            )
            pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(pcenter.fac2cli, dtype=object),
                numpy.array(pcenter_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 4 / 5 (80%)
    E        x: array([list([5, 18, 19, 22, 25, 28, 32, 47, 48, 54, 62, 68, 72]),
    E              list([0, 1, 9, 10, 12, 13, 15, 17, 20, 21, 29, 38, 43, 44, 46, 50, 57, 59, 60, 69, 73, 74, 75, 79, 81, 84, 86, 91, 92, 94, 95, 99]),
    E              list([2, 3, 4, 6, 7, 8, 23, 26, 31, 33, 34, 35, 37, 40, 49, 52, 58, 61, 63, 65, 66, 70, 78, 80, 82, 89, 90, 93, 96, 97]),...
    E        y: array([list([5, 18, 19, 22, 28, 32, 34, 36, 48, 53, 62, 72, 90, 96]),
    E              list([0, 9, 10, 12, 13, 15, 17, 20, 21, 29, 37, 46, 50, 60, 64, 73, 75, 79, 81, 84, 86, 91, 92, 94, 95, 99]),
    E              list([2, 3, 4, 6, 7, 8, 23, 25, 26, 31, 33, 35, 43, 44, 47, 49, 52, 54, 57, 58, 59, 61, 63, 65, 66, 69, 70, 74, 78, 80, 82, 89, 93, 97]),...
    
    spopt/tests/test_locate.py:439: AssertionError
    __________________________________________ TestSyntheticLocate.test_pcenter_client_facility_array_from_geodataframe ___________________________________________
    [gw3] darwin -- Python 3.10.6 /Users/user/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x1635b5090>
    
        def test_pcenter_client_facility_array_from_geodataframe(self):
            with open(self.dirpath + "pcenter_geodataframe_cli2fac.pkl", "rb") as f:
                pcenter_objective = pickle.load(f)
        
            pcenter = PCenter.from_geodataframe(
                self.clients_snapped,
                self.facilities_snapped,
                "geometry",
                "geometry",
                p_facilities=4,
            )
            pcenter = pcenter.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(pcenter.cli2fac, dtype=object),
                numpy.array(pcenter_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 20 / 100 (20%)
    E       Max absolute difference: 4
    E       Max relative difference: 3.0
    E        x: array([[1],
    E              [1],
    E              [2],...
    E        y: array([[1],
    E              [4],
    E              [2],...
    
    spopt/tests/test_locate.py:457: AssertionError
    

Same to true for the MCLP (see here).

  • MCLP failures
    ____________________________________________ TestSyntheticLocate.test_mclp_facility_client_array_from_cost_matrix _____________________________________________
    [gw2] darwin -- Python 3.10.6 /Users/the-gaboardi/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x166d67ca0>
    
        def test_mclp_facility_client_array_from_cost_matrix(self):
            with open(self.dirpath + "mclp_fac2cli.pkl", "rb") as f:
                mclp_objective = pickle.load(f)
        
            mclp = MCLP.from_cost_matrix(
                self.cost_matrix,
                self.ai,
                service_radius=7,
                p_facilities=4,
            )
            mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(mclp.fac2cli, dtype=object),
                numpy.array(mclp_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 2 / 5 (40%)
    E        x: array([list([2, 3, 5, 6, 7, 8, 11, 16, 18, 19, 22, 25, 26, 28, 32, 33, 34, 35, 36, 39, 40, 41, 47, 48, 49, 52, 53, 54, 58, 61, 62, 63, 65, 68, 70, 72, 78, 80, 82, 85, 86, 89, 90, 96]),
    E              list([0, 1, 2, 4, 6, 7, 9, 10, 12, 13, 15, 17, 20, 21, 24, 26, 29, 33, 35, 37, 38, 43, 44, 46, 49, 50, 51, 52, 55, 57, 58, 59, 60, 61, 63, 64, 67, 69, 73, 74, 75, 76, 78, 79, 81, 82, 84, 86, 89, 91, 92, 94, 95, 99]),
    E              list([2, 3, 4, 5, 6, 7, 8, 11, 13, 15, 17, 18, 19, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 37, 38, 40, 41, 43, 44, 45, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 72, 74, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96]),...
    E        y: array([list([2, 3, 5, 6, 7, 8, 11, 16, 18, 19, 22, 25, 26, 28, 32, 33, 34, 35, 36, 39, 40, 41, 47, 48, 49, 52, 53, 54, 58, 61, 62, 63, 65, 68, 70, 72, 78, 80, 82, 85, 86, 89, 90, 96]),
    E              list([0, 1, 2, 4, 6, 7, 9, 10, 12, 13, 15, 17, 20, 21, 24, 26, 29, 33, 35, 37, 38, 43, 44, 46, 49, 50, 51, 52, 55, 57, 58, 59, 60, 61, 63, 64, 67, 69, 73, 74, 75, 76, 78, 79, 81, 82, 84, 86, 89, 91, 92, 94, 95, 99]),
    E              list([2, 3, 4, 5, 6, 7, 8, 11, 13, 15, 17, 18, 19, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 37, 38, 40, 41, 43, 44, 45, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 72, 74, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96]),...
    
    spopt/tests/test_locate.py:204: AssertionError
    ____________________________________________ TestSyntheticLocate.test_mclp_client_facility_array_from_cost_matrix _____________________________________________
    [gw3] darwin -- Python 3.10.6 /Users/the-gaboardi/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x166c94670>
    
        def test_mclp_client_facility_array_from_cost_matrix(self):
            with open(self.dirpath + "mclp_cli2fac.pkl", "rb") as f:
                mclp_objective = pickle.load(f)
        
            mclp = MCLP.from_cost_matrix(
                self.cost_matrix,
                self.ai,
                service_radius=7,
                p_facilities=4,
            )
            mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(mclp.cli2fac, dtype=object),
                numpy.array(mclp_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 82 / 100 (82%)
    E        x: array([list([1, 4]), list([1, 4]), list([0, 1, 2, 4]), list([0, 2, 4]),
    E              list([1, 2]), list([0, 2]), list([0, 1, 2]), list([0, 1, 2, 4]),
    E              list([0, 2]), list([1, 4]), list([1]), list([0, 2, 4]), list([1]),...
    E        y: array([list([1, 3]), list([1, 3]), list([0, 1, 2, 3]), list([0, 2, 3]),
    E              list([1, 2, 3]), list([0, 2]), list([0, 1, 2, 3]),
    E              list([0, 1, 2, 3]), list([0, 2, 3]), list([1]), list([1]),...
    
    spopt/tests/test_locate.py:221: AssertionError
    ____________________________________________ TestSyntheticLocate.test_mclp_facility_client_array_from_geodataframe ____________________________________________
    [gw1] darwin -- Python 3.10.6 /Users/the-gaboardi/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x166bb8400>
    
        def test_mclp_facility_client_array_from_geodataframe(self):
            with open(self.dirpath + "mclp_geodataframe_fac2cli.pkl", "rb") as f:
                mclp_objective = pickle.load(f)
        
            mclp = MCLP.from_geodataframe(
                self.clients_snapped,
                self.facilities_snapped,
                "geometry",
                "geometry",
                "weights",
                service_radius=7,
                p_facilities=4,
            )
            mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(mclp.fac2cli, dtype=object),
                numpy.array(mclp_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 2 / 5 (40%)
    E        x: array([list([]),
    E              list([0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19, 20, 21, 23, 24, 26, 27, 29, 30, 31, 33, 35, 37, 38, 41, 43, 44, 45, 46, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 60, 61, 63, 64, 65, 66, 67, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 99]),
    E              list([0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]),...
    E        y: array([list([2, 3, 4, 5, 6, 7, 8, 11, 16, 18, 19, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 47, 48, 49, 52, 53, 54, 55, 56, 58, 61, 62, 63, 65, 66, 67, 68, 69, 70, 72, 76, 78, 80, 82, 83, 85, 86, 88, 89, 90, 93, 96, 98]),
    E              list([0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19, 20, 21, 23, 24, 26, 27, 29, 30, 31, 33, 35, 37, 38, 41, 43, 44, 45, 46, 47, 49, 50, 51, 52, 54, 55, 57, 58, 59, 60, 61, 63, 64, 65, 66, 67, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 99]),
    E              list([0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]),...
    
    spopt/tests/test_locate.py:255: AssertionError
    ____________________________________________ TestSyntheticLocate.test_mclp_client_facility_array_from_geodataframe ____________________________________________
    [gw3] darwin -- Python 3.10.6 /Users/the-gaboardi/miniconda3/envs/py310_spopt/bin/python
    
    self = <spopt.tests.test_locate.TestSyntheticLocate object at 0x166c94bb0>
    
        def test_mclp_client_facility_array_from_geodataframe(self):
            with open(self.dirpath + "mclp_geodataframe_cli2fac.pkl", "rb") as f:
                mclp_objective = pickle.load(f)
        
            mclp = MCLP.from_geodataframe(
                self.clients_snapped,
                self.facilities_snapped,
                "geometry",
                "geometry",
                "weights",
                service_radius=7,
                p_facilities=4,
            )
            mclp = mclp.solve(pulp.PULP_CBC_CMD(msg=False))
        
    >       numpy.testing.assert_array_equal(
                numpy.array(mclp.cli2fac, dtype=object),
                numpy.array(mclp_objective, dtype=object),
            )
    E       AssertionError: 
    E       Arrays are not equal
    E       
    E       Mismatched elements: 99 / 100 (99%)
    E        x: array([list([1, 2, 3, 4]), list([1, 2, 3, 4]), list([1, 2, 3, 4]),
    E              list([1, 2, 3, 4]), list([1, 2, 3]), list([2, 3]), list([1, 2, 3]),
    E              list([1, 2, 3, 4]), list([1, 2, 3]), list([1, 3, 4]),...
    E        y: array([list([1, 2, 4]), list([1, 2, 4]), list([0, 1, 2, 4]),
    E              list([0, 1, 2, 4]), list([0, 1, 2]), list([0, 2]), list([0, 1, 2]),
    E              list([0, 1, 2, 4]), list([0, 1, 2]), list([1, 4]), list([1, 2]),...
    
    spopt/tests/test_locate.py:302: AssertionError
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant