From 7cc64e5625013b06bc8a4196c771e28395ca7a00 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Wed, 1 Nov 2023 16:51:21 +0100 Subject: [PATCH 01/13] Clean up test_customizedbenders --- tests/test_customizedbenders.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_customizedbenders.py b/tests/test_customizedbenders.py index d72c7942c..146d80279 100644 --- a/tests/test_customizedbenders.py +++ b/tests/test_customizedbenders.py @@ -188,7 +188,7 @@ def make_data(): return I,J,d,M,f,c -def test_flpbenders_defcuts(): +def flpbenders_defcuts_test(): ''' test the Benders' decomposition plugins with the facility location problem. ''' @@ -235,7 +235,7 @@ def test_flpbenders_defcuts(): return master.getObjVal() -def test_flpbenders_customcuts(): +def flpbenders_customcuts_test(): ''' test the Benders' decomposition plugins with the facility location problem. ''' @@ -285,7 +285,7 @@ def test_flpbenders_customcuts(): return master.getObjVal() -def test_flp(): +def flp_test(): ''' test the Benders' decomposition plugins with the facility location problem. ''' @@ -309,10 +309,11 @@ def test_flp(): return master.getObjVal() -if __name__ == "__main__": - defcutsobj = test_flpbenders_defcuts() - customcutsobj = test_flpbenders_customcuts() - monolithicobj = test_flp() + +def test_customized_benders(): + defcutsobj = flpbenders_defcuts_test() + customcutsobj = flpbenders_customcuts_test() + monolithicobj = flp_test() assert defcutsobj == customcutsobj assert defcutsobj == monolithicobj From fec98e32f776da1c1cf6ac9912448e2a485b7c0c Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Wed, 1 Nov 2023 17:00:11 +0100 Subject: [PATCH 02/13] Remove __name__ == "__main__" --- tests/test_alldiff.py | 5 +---- tests/test_benders.py | 6 +----- tests/test_branch_probing_lp.py | 5 +---- tests/test_conshdlr.py | 5 +---- tests/test_copy.py | 3 --- tests/test_cutsel.py | 4 ---- tests/test_event.py | 3 --- tests/test_gomory.py | 3 --- tests/test_heur.py | 3 --- tests/test_knapsack.py | 5 +---- tests/test_lp.py | 3 --- tests/test_memory.py | 6 +----- tests/test_model.py | 9 --------- tests/test_nlrow.py | 3 --- tests/test_nodesel.py | 6 +----- tests/test_nonlinear.py | 9 +-------- tests/test_pricer.py | 7 +------ tests/test_quadcons.py | 6 +----- tests/test_quickprod.py | 5 ----- tests/test_quicksum.py | 5 ----- tests/test_reader.py | 8 ++------ tests/test_relax.py | 6 +----- tests/test_solution.py | 5 ----- tests/test_tree.py | 5 +---- tests/test_tsp.py | 6 +----- tests/test_vars.py | 6 +----- 26 files changed, 16 insertions(+), 121 deletions(-) diff --git a/tests/test_alldiff.py b/tests/test_alldiff.py index efe9bec47..c14dd1bff 100644 --- a/tests/test_alldiff.py +++ b/tests/test_alldiff.py @@ -298,7 +298,4 @@ def test_main(): out = '' for col in range(9): out += str(round(scip.getVal(x[row,col]))) + ' ' - print(out) - -if __name__ == "__main__": - test_main() + print(out) \ No newline at end of file diff --git a/tests/test_benders.py b/tests/test_benders.py index c4a72df51..2273b5d48 100644 --- a/tests/test_benders.py +++ b/tests/test_benders.py @@ -106,8 +106,4 @@ def test_flpbenders(): # the solution will be lost master.freeBendersSubproblems() - assert master.getObjVal() == 5.61e+03 - - -if __name__ == "__main__": - test_flpbenders() + assert master.getObjVal() == 5.61e+03 \ No newline at end of file diff --git a/tests/test_branch_probing_lp.py b/tests/test_branch_probing_lp.py index 45fd8e724..b699ce9a1 100644 --- a/tests/test_branch_probing_lp.py +++ b/tests/test_branch_probing_lp.py @@ -92,7 +92,4 @@ def test_branching(): print("t", m.getVal(t)) assert my_branchrule.was_called_val - assert my_branchrule.was_called_int - -if __name__ == "__main__": - test_branching() + assert my_branchrule.was_called_int \ No newline at end of file diff --git a/tests/test_conshdlr.py b/tests/test_conshdlr.py index 45c42852f..9b27a8c2d 100644 --- a/tests/test_conshdlr.py +++ b/tests/test_conshdlr.py @@ -249,7 +249,4 @@ def create_model(): assert "consdisable" in calls #assert "consdelvars" in calls #assert "consprint" in calls - assert "consgetnvars" in calls - -if __name__ == "__main__": - test_conshdlr() + assert "consgetnvars" in calls \ No newline at end of file diff --git a/tests/test_copy.py b/tests/test_copy.py index b256452f2..b518d0a13 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -18,6 +18,3 @@ def test_copy(): s2.optimize() assert s.getObjVal() == s2.getObjVal() - -if __name__ == "__main__": - test_copy() diff --git a/tests/test_cutsel.py b/tests/test_cutsel.py index a0c193031..22d5ac45d 100644 --- a/tests/test_cutsel.py +++ b/tests/test_cutsel.py @@ -79,7 +79,3 @@ def test_cut_selector(): scip.setObjective(quicksum(c[i] * e[i] for i in range(len(A))), sense='minimize') scip.optimize() - - -if __name__ == "__main__": - test_cut_selector() diff --git a/tests/test_event.py b/tests/test_event.py index b595945b7..72c518073 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -48,6 +48,3 @@ def test_event(): assert 'eventexit' in calls assert 'eventexec' in calls assert len(calls) == 3 - -if __name__ == "__main__": - test_event() diff --git a/tests/test_gomory.py b/tests/test_gomory.py index b6f209b3c..b95537045 100644 --- a/tests/test_gomory.py +++ b/tests/test_gomory.py @@ -340,6 +340,3 @@ def test_CKS(): # solve problem s.optimize() s.printStatistics() - -if __name__ == "__main__": - test_CKS() diff --git a/tests/test_heur.py b/tests/test_heur.py index 1f1ade8fe..3ec3d62ba 100644 --- a/tests/test_heur.py +++ b/tests/test_heur.py @@ -64,6 +64,3 @@ def inner(): heur_prox.name assert is_memory_freed() - -if __name__ == "__main__": - test_heur() diff --git a/tests/test_knapsack.py b/tests/test_knapsack.py index 359f3256b..2634a4a24 100644 --- a/tests/test_knapsack.py +++ b/tests/test_knapsack.py @@ -45,7 +45,4 @@ def test_knapsack(): print ("\tIncluded Weight:", weights[i]*solValue, "\tItem Cost:", costs[i]*solValue) includedWeight = sum([weights[i]*varSolutions[i] for i in range(len(weights))]) - assert includedWeight > 0 and includedWeight <= knapsackSize - -if __name__ == "__main__": - test_knapsack() + assert includedWeight > 0 and includedWeight <= knapsackSize \ No newline at end of file diff --git a/tests/test_lp.py b/tests/test_lp.py index 98314e487..299ce122c 100644 --- a/tests/test_lp.py +++ b/tests/test_lp.py @@ -20,6 +20,3 @@ def test_lp(): solval = myLP.solve() assert round(5.0 == solval) - -if __name__ == "__main__": - test_lp() diff --git a/tests/test_memory.py b/tests/test_memory.py index 13735687d..173d109ab 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -13,8 +13,4 @@ def test_freed(): pytest.skip() m = Model() del m - assert is_memory_freed() - -if __name__ == "__main__": - test_not_freed() - test_freed() + assert is_memory_freed() \ No newline at end of file diff --git a/tests/test_model.py b/tests/test_model.py index f86fac33b..aa987a448 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -182,12 +182,3 @@ def test_model_ptr(): with pytest.raises(ValueError): Model.from_ptr("some gibberish", take_ownership=False) - - -if __name__ == "__main__": - test_model() - test_solve_concurrent() - test_multiple_cons_simple() - test_multiple_cons_names() - test_multiple_cons_params() - test_model_ptr() diff --git a/tests/test_nlrow.py b/tests/test_nlrow.py index 63e12d68e..94b876ca1 100644 --- a/tests/test_nlrow.py +++ b/tests/test_nlrow.py @@ -65,6 +65,3 @@ def test_nlrow(): linterms = nlrows[2].getLinearTerms() assert len(linterms) == 0 - -if __name__ == "__main__": - test_nlrow() diff --git a/tests/test_nodesel.py b/tests/test_nodesel.py index 665ac07ee..2fa4254e9 100644 --- a/tests/test_nodesel.py +++ b/tests/test_nodesel.py @@ -41,8 +41,4 @@ def test_nodesel(): m.addCons(x1 * x2 >= x0) m.setObjective(x1 + x0) - m.optimize() - - -if __name__ == "__main__": - test_nodesel() + m.optimize() \ No newline at end of file diff --git a/tests/test_nonlinear.py b/tests/test_nonlinear.py index 35df5a14f..528ed383c 100644 --- a/tests/test_nonlinear.py +++ b/tests/test_nonlinear.py @@ -284,11 +284,4 @@ def test_quad_coeffs(): assert quadterms[0][1] == 0.5 assert linterms[0][0].name == z.name - assert linterms[0][1] == 4 - -if __name__ == "__main__": - test_string_poly() - test_string() - test_circle() - test_gastrans() - test_quad_coeffs() + assert linterms[0][1] == 4 \ No newline at end of file diff --git a/tests/test_pricer.py b/tests/test_pricer.py index 111b0452e..7c7a83e2e 100644 --- a/tests/test_pricer.py +++ b/tests/test_pricer.py @@ -155,9 +155,4 @@ class IncompletePricer(Pricer): model.includePricer(pricer, "", "") with pytest.raises(Exception): - model.optimize() - - -if __name__ == '__main__': - test_cuttingstock() - test_incomplete_pricer() + model.optimize() \ No newline at end of file diff --git a/tests/test_quadcons.py b/tests/test_quadcons.py index 6170a7375..3c378c189 100644 --- a/tests/test_quadcons.py +++ b/tests/test_quadcons.py @@ -25,8 +25,4 @@ def test_niceqcqp(): s.optimize() assert round(s.getVal(x)) == 1.0 - assert round(s.getVal(y)) == 1.0 - -if __name__ == "__main__": - test_niceqp() - test_niceqcqp() + assert round(s.getVal(y)) == 1.0 \ No newline at end of file diff --git a/tests/test_quickprod.py b/tests/test_quickprod.py index 04b26e2c6..70e767047 100644 --- a/tests/test_quickprod.py +++ b/tests/test_quickprod.py @@ -35,8 +35,3 @@ def test_largequadratic(): assert cons.expr.degree() == 2*dim*dim m.addCons(cons) # TODO: what can we test beyond the lack of crashes? - -if __name__ == "__main__": - test_quickprod() - test_quickprod_model() - test_largequadratic() diff --git a/tests/test_quicksum.py b/tests/test_quicksum.py index 83c5de11a..3ac8f26ae 100644 --- a/tests/test_quicksum.py +++ b/tests/test_quicksum.py @@ -33,8 +33,3 @@ def test_largequadratic(): assert len(cons.expr.terms) == dim * (dim-1) / 2 + dim m.addCons(cons) # TODO: what can we test beyond the lack of crashes? - -if __name__ == "__main__": - test_quicksum() - test_quicksum_model() - test_largequadratic() diff --git a/tests/test_reader.py b/tests/test_reader.py index 6debe458e..b812560ff 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -59,7 +59,7 @@ def createFile(filename): def deleteFile(filename): os.remove(filename) -def test(): +def test_main(): createFile("tmp.sod") m = Model("soduko") @@ -78,8 +78,4 @@ def test(): input = f.readline() assert input == "soduko" - deleteFile("model.sod") - - -if __name__ == "__main__": - test() + deleteFile("model.sod") \ No newline at end of file diff --git a/tests/test_relax.py b/tests/test_relax.py index 480cd9040..5ecdfed23 100644 --- a/tests/test_relax.py +++ b/tests/test_relax.py @@ -29,8 +29,4 @@ def test_relax(): m.optimize() assert 'relaxexec' in calls - assert len(calls) >= 1 - - -if __name__ == "__main__": - test_relax() + assert len(calls) >= 1 \ No newline at end of file diff --git a/tests/test_solution.py b/tests/test_solution.py index 497c6d52c..e2927bfdb 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -61,8 +61,3 @@ def test_solution_evaluation(): assert sol[y] == m.getVal(y) assert sol[expr] == m.getVal(expr) assert sol[expr2] == m.getVal(expr2) - - -if __name__ == "__main__": - test_solution_getbest() - test_solution_create() diff --git a/tests/test_tree.py b/tests/test_tree.py index 74f0c7e69..58b121508 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -60,7 +60,4 @@ def test_tree(): del s - assert len(node_eventhdlr.calls) > 3 - -if __name__ == "__main__": - test_tree() + assert len(node_eventhdlr.calls) > 3 \ No newline at end of file diff --git a/tests/test_tsp.py b/tests/test_tsp.py index c6fb86dad..127fc267c 100644 --- a/tests/test_tsp.py +++ b/tests/test_tsp.py @@ -111,8 +111,4 @@ def test_main(): objective_value, edges = solve_tsp(vertices, distance) print("Optimal tour:", edges) - print("Optimal cost:", objective_value) - - -if __name__ == "__main__": - test_main() + print("Optimal cost:", objective_value) \ No newline at end of file diff --git a/tests/test_vars.py b/tests/test_vars.py index b55366a80..d8c92ff40 100644 --- a/tests/test_vars.py +++ b/tests/test_vars.py @@ -64,8 +64,4 @@ def test_vtype(): assert x.vtype() == "INTEGER" m.chgVarType(y, 'M') - assert y.vtype() == "IMPLINT" - -if __name__ == "__main__": - test_variablebounds() - test_vtype() + assert y.vtype() == "IMPLINT" \ No newline at end of file From ed54375aae1b1656840a0960041465fe144b1032 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 10:25:00 +0100 Subject: [PATCH 03/13] Add test_getSolTime --- tests/test_solution.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_solution.py b/tests/test_solution.py index e2927bfdb..8243542ab 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -1,4 +1,4 @@ -from pyscipopt import Model +from pyscipopt import Model, SCIP_PARAMSETTING, quicksum, quickprod def test_solution_getbest(): @@ -61,3 +61,20 @@ def test_solution_evaluation(): assert sol[y] == m.getVal(y) assert sol[expr] == m.getVal(expr) assert sol[expr2] == m.getVal(expr2) + +def test_getSolTime(): + m = Model() + m.setPresolve(SCIP_PARAMSETTING.OFF) + + x = {} + for i in range(20): + x[i] = m.addVar(ub=i) + + for i in range(1,6): + m.addCons(quicksum(x[j] for j in range(20) if j%i==0) >= i) + m.addCons(quickprod(x[j] for j in range(20) if j%i==0) <= i**3) + + m.setObjective(quicksum(x[i] for i in range(20))) + m.optimize() + for s in m.getSols(): + assert type(m.getSolTime(s)) == float From b8282bc4f0409a4b75ac474e1cf9b2ca13ae7a48 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 10:54:03 +0100 Subject: [PATCH 04/13] Add test for getVarRedcost --- tests/test_pricer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_pricer.py b/tests/test_pricer.py index 7c7a83e2e..08a9c2ed3 100644 --- a/tests/test_pricer.py +++ b/tests/test_pricer.py @@ -10,6 +10,7 @@ def pricerredcost(self): dualSolutions = [] for i, c in enumerate(self.data['cons']): dualSolutions.append(self.model.getDualsolLinear(c)) + #assert self.model.getDualsolLinear(c) == self.model.getDualSolVal(c) # Building a MIP to solve the subproblem subMIP = Model("CuttingStock-Sub") @@ -38,6 +39,7 @@ def pricerredcost(self): objval = 1 + subMIP.getObjVal() + # Adding the column to the master problem if objval < -1e-08: currentNumVar = len(self.data['var']) @@ -53,6 +55,9 @@ def pricerredcost(self): newPattern.append(coeff) + # Testing getVarRedcost + assert round(self.model.getVarRedcost(newVar),6) == round(objval,6) + # Storing the new variable in the pricer data. self.data['patterns'].append(newPattern) self.data['var'].append(newVar) @@ -112,6 +117,7 @@ def test_cuttingstock(): pricer.data['demand'] = demand pricer.data['rollLength'] = rollLength pricer.data['patterns'] = patterns + pricer.data['redcosts'] = [] # solve problem s.optimize() @@ -142,7 +148,7 @@ def test_cuttingstock(): print(outline) print('\t\t\tTotal Output:\t', '\t'.join(str(e) for e in widthOutput)) - + assert s.getObjVal() == 452.25 def test_incomplete_pricer(): From cf69d027803e813ba3bda1c44d192b054acfda76 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 11:06:51 +0100 Subject: [PATCH 05/13] Add test for getConss, getNConss --- tests/test_model.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index aa987a448..1ca806564 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -141,6 +141,8 @@ def test_multiple_cons_names(): assert len(conss) == 5 assert all([c.name.startswith(name + "_") for c in conss]) + assert conss == m.getConss() + assert m.getNConss() == 5 def test_multiple_cons_params(): From 59980b740dfedb86ee7a2c6edd75588290f597d9 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 11:13:20 +0100 Subject: [PATCH 06/13] Add test for getNNlRows, printNlRow --- tests/test_nlrow.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_nlrow.py b/tests/test_nlrow.py index 94b876ca1..64bed80ce 100644 --- a/tests/test_nlrow.py +++ b/tests/test_nlrow.py @@ -35,6 +35,13 @@ def test_nlrow(): # collect nonlinear rows nlrows = m.getNlRows() + + # test getNNlRows + assert len(nlrows) == m.getNNlRows() + + # to test printing of NLRows + for row in nlrows: + m.printNlRow(row) # the nlrow that corresponds to the linear (third) constraint is added before the nonlinear rows, # because Initsol of the linear conshdlr gets called first From 7b5fab5f887de1afd3381f6245b7bee2eca9029d Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 11:33:47 +0100 Subject: [PATCH 07/13] Add test for add/del/chgCoefLinear --- tests/test_model.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index 1ca806564..0c2dabf63 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -172,6 +172,38 @@ def assert_conss_neq(a, b): assert_conss_neq(conss[0], conss[1]) +def test_addCoefLinear(): + m = Model() + x = m.addVar(obj=1) + y = m.addVar() + c = m.addCons(x >= 1) + + m.addCoefLinear(c, y, 1) + + m.optimize() + assert m.getVal(x) == 0 + +def test_delCoefLinear(): + m = Model() + x = m.addVar(obj=1) + y = m.addVar(obj=0) + c = m.addCons(x + y >= 1) + + m.delCoefLinear(c,y) + + m.optimize() + assert m.getVal(x) == 1 + +def test_chgCoefLinear(): + m = Model() + x = m.addVar(obj=10) + y = m.addVar(obj=1) + c = m.addCons(x + y >= 1) + + m.chgCoefLinear(c, y, 0.001) + + m.optimize() + assert m.getObjVal() == 10 def test_model_ptr(): model1 = Model() From 5930777bb425d4a5d52ad89d00130aabb38dab57 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 11:34:10 +0100 Subject: [PATCH 08/13] Add tests for setting cons options --- tests/test_cons.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_cons.py diff --git a/tests/test_cons.py b/tests/test_cons.py new file mode 100644 index 000000000..55f67f25b --- /dev/null +++ b/tests/test_cons.py @@ -0,0 +1,19 @@ +import pytest + +from pyscipopt import Model + +def test_constraint_option_setting(): + m = Model() + x = m.addVar() + c = m.addCons(x >= 3) + + for option in [True, False]: + m.setCheck(c, option) + m.setEnforced(c, option) + m.setRemovable(c, option) + m.setInitial(c, option) + + assert c.isChecked() == option + assert c.isEnforced() == option + assert c.isRemovable() == option + assert c.isInitial() == option From 61f1450ae31b47bc69b1b8edbdb91d46d1ed671f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dion=C3=ADsio?= <57299939+Joao-Dionisio@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:47:20 +0000 Subject: [PATCH 09/13] Update test_solution.py --- tests/test_solution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_solution.py b/tests/test_solution.py index cb2c40796..a202c6dd1 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -77,7 +77,7 @@ def test_getSolTime(): m.setObjective(quicksum(x[i] for i in range(20))) m.optimize() for s in m.getSols(): - m.getSolTime(s)) + m.getSolTime(s) def test_create_solution(): with pytest.raises(ValueError): @@ -98,4 +98,4 @@ def test_getSols(): m.optimize() assert len(m.getSols()) >= 1 - assert any(sol[x] == 0.0 for sol in m.getSols()) \ No newline at end of file + assert any(sol[x] == 0.0 for sol in m.getSols()) From 7398a9324424e3847dea210c4523326606cc7e75 Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Fri, 3 Nov 2023 12:39:53 +0100 Subject: [PATCH 10/13] Fix sudoku typo --- tests/test_reader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_reader.py b/tests/test_reader.py index b812560ff..2f4712271 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -59,13 +59,13 @@ def createFile(filename): def deleteFile(filename): os.remove(filename) -def test_main(): +def test_sudoku_reader(): createFile("tmp.sod") - m = Model("soduko") + m = Model("sudoku") reader = SudokuReader() - m.includeReader(reader, "sodreader", "PyReader for soduko problem", "sod") + m.includeReader(reader, "sudreader", "PyReader for sudoku problem", "sod") m.readProblem("tmp.sod") @@ -76,6 +76,6 @@ def test_main(): m.writeProblem("model.sod") with open("model.sod", "r") as f: input = f.readline() - assert input == "soduko" + assert input == "sudoku" deleteFile("model.sod") \ No newline at end of file From f01ace05e3b076afef47817d613abf89fd87917c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dion=C3=ADsio?= <57299939+Joao-Dionisio@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:44:19 +0000 Subject: [PATCH 11/13] Update test_model.py --- tests/test_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index de764e1b6..991d95e1b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -175,7 +175,7 @@ def assert_conss_neq(a, b): def test_addCoefLinear(): m = Model() x = m.addVar(obj=1) - y = m.addVar() + y = m.addVar(obj=0) c = m.addCons(x >= 1) m.addCoefLinear(c, y, 1) @@ -250,4 +250,4 @@ def test_getVarsDict(): var_dict = model.getVarDict() for v in x.values(): assert v.name in var_dict - assert model.getVal(v) == var_dict[v.name] \ No newline at end of file + assert model.getVal(v) == var_dict[v.name] From 20f75f1f3ec2c264a4ad734d0094972efaa09d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dion=C3=ADsio?= <57299939+Joao-Dionisio@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:47:59 +0000 Subject: [PATCH 12/13] Update test_solution.py --- tests/test_solution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_solution.py b/tests/test_solution.py index a202c6dd1..933dfa5de 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -77,7 +77,7 @@ def test_getSolTime(): m.setObjective(quicksum(x[i] for i in range(20))) m.optimize() for s in m.getSols(): - m.getSolTime(s) + assert m.getSolTime(s) >= 0 def test_create_solution(): with pytest.raises(ValueError): From a31ab0f166c867f936cedd9f16f3302566ed5c6e Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Mon, 6 Nov 2023 09:32:57 +0100 Subject: [PATCH 13/13] Remove comment --- tests/test_pricer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_pricer.py b/tests/test_pricer.py index 08a9c2ed3..ebae4eb46 100644 --- a/tests/test_pricer.py +++ b/tests/test_pricer.py @@ -10,7 +10,6 @@ def pricerredcost(self): dualSolutions = [] for i, c in enumerate(self.data['cons']): dualSolutions.append(self.model.getDualsolLinear(c)) - #assert self.model.getDualsolLinear(c) == self.model.getDualSolVal(c) # Building a MIP to solve the subproblem subMIP = Model("CuttingStock-Sub")