def test_include_equality_scalar_bound(self): rhs = 2 aop = AbstractOptimizationProblem() x = aop.create_variable('x', 2) g = 2 * x aop.include_equality(g, rhs=rhs) self.assertTrue(is_equal(aop.g_lb, repmat(rhs, 2))) self.assertTrue(is_equal(aop.g_ub, repmat(rhs, 2)))
def test_include_equality(self): aop = AbstractOptimizationProblem() x = aop.create_variable('x', 2) g = x[0] - x[1] aop.include_equality(g) self.assertTrue(is_equal(aop.g, g)) self.assertTrue(is_equal(aop.g_lb, 0)) self.assertTrue(is_equal(aop.g_ub, 0))
def test_include_equality_with_bounds(self): rhs = 2 aop = AbstractOptimizationProblem() x = aop.create_variable('x', 2) g = x[0] - x[1] aop.include_equality(g, rhs=rhs) self.assertTrue(is_equal(aop.g, g)) self.assertTrue(is_equal(aop.g_lb, rhs)) self.assertTrue(is_equal(aop.g_ub, rhs))
def test_include_equality_w_external_variable_in_expr(self): theta = MX.sym('theta') aop = AbstractOptimizationProblem() x = aop.create_variable('x', 2) g = theta * x[0] - x[1] aop.include_equality(g) self.assertTrue(is_equal(aop.g, g)) self.assertTrue(is_equal(aop.g_lb, 0)) self.assertTrue(is_equal(aop.g_ub, 0))