Exemplo n.º 1
0
 def test_add_differing_interface_type_raises(self):
     from optlang import glpk_interface as glpk
     x, y = glpk.Variable('x'), glpk.Variable('y')
     constraint = glpk.Constraint(x + y)
     objective = glpk.Objective(1. * x)
     self.assertRaises(TypeError, self.model.add, x)
     self.assertRaises(TypeError, self.model.add, constraint)
     self.assertRaises(TypeError, self.model.add, objective)
Exemplo n.º 2
0
 def test_clone_constraint_glpk_to_cplex(self):
     x1 = glpk.Variable('x1', lb=0)
     x2 = glpk.Variable('x2', lb=0)
     x3 = glpk.Variable('x3', lb=0)
     c1 = glpk.Constraint(x1 + x2 + x3, ub=100)
     cplex_c1 = cplex.Constraint.clone(c1)
     print(cplex_c1)
     self.assertIs(cplex_c1.__class__, cplex.Constraint)
     for variable in cplex_c1.variables:
         self.assertIs(variable.__class__, cplex.Variable)