Exemple #1
0
 def test_ipopt_solver(self):
     prog, x, x_expected = self._make_prog()
     solver = IpoptSolver()
     self.assertTrue(solver.available())
     self.assertEqual(solver.solver_id().name(), "IPOPT")
     self.assertEqual(solver.SolverName(), "IPOPT")
     self.assertEqual(solver.solver_type(), mp.SolverType.kIpopt)
     result = solver.Solve(prog, None, None)
     self.assertTrue(result.is_success())
     self.assertTrue(np.allclose(result.GetSolution(x), x_expected))
Exemple #2
0
 def test_ipopt_solver(self):
     prog = mp.MathematicalProgram()
     x = prog.NewContinuousVariables(2, "x")
     prog.AddLinearConstraint(x[0] >= 1)
     prog.AddLinearConstraint(x[1] >= 1)
     prog.AddQuadraticCost(np.eye(2), np.zeros(2), x)
     solver = IpoptSolver()
     self.assertTrue(solver.available())
     self.assertEqual(solver.SolverName(), "IPOPT")
     self.assertEqual(solver.solver_type(), mp.SolverType.kIpopt)
     result = solver.Solve(prog)
     self.assertEqual(result, mp.SolutionResult.kSolutionFound)
     x_expected = np.array([1, 1])
     self.assertTrue(np.allclose(prog.GetSolution(x), x_expected))
Exemple #3
0
 def test_ipopt_solver(self):
     prog = mp.MathematicalProgram()
     x = prog.NewContinuousVariables(2, "x")
     prog.AddLinearConstraint(x[0] >= 1)
     prog.AddLinearConstraint(x[1] >= 1)
     prog.AddQuadraticCost(np.eye(2), np.zeros(2), x)
     solver = IpoptSolver()
     self.assertTrue(solver.available())
     self.assertEqual(solver.solver_id().name(), "IPOPT")
     self.assertEqual(solver.SolverName(), "IPOPT")
     self.assertEqual(solver.solver_type(), mp.SolverType.kIpopt)
     result = solver.Solve(prog)
     self.assertEqual(result, mp.SolutionResult.kSolutionFound)
     x_expected = np.array([1, 1])
     self.assertTrue(np.allclose(prog.GetSolution(x), x_expected))
 def test_ipopt_solver(self):
     prog, x, x_expected = self._make_prog()
     solver = IpoptSolver()
     self.assertTrue(solver.available())
     self.assertEqual(solver.solver_id().name(), "IPOPT")
     self.assertEqual(solver.SolverName(), "IPOPT")
     self.assertEqual(solver.solver_type(), mp.SolverType.kIpopt)
     result = solver.Solve(prog, None, None)
     self.assertTrue(result.is_success())
     self.assertTrue(np.allclose(result.GetSolution(x), x_expected))
     self.assertEqual(result.get_solver_details().status, 0)
     self.assertEqual(result.get_solver_details().ConvertStatusToString(),
                      "Success")
     np.testing.assert_allclose(result.get_solver_details().z_L,
                                np.array([1., 1.]))
     np.testing.assert_allclose(result.get_solver_details().z_U,
                                np.array([0., 0.]))
     np.testing.assert_allclose(result.get_solver_details().g, np.array([]))
     np.testing.assert_allclose(result.get_solver_details().lambda_val,
                                np.array([]))