Testing expr_t, that allows adding constraints that are not aligned with integrator timesteps
(self)
| 259 | self.assertRaises(RuntimeError, problem.solve) |
| 260 | |
| 261 | def test_expr_t(self): |
| 262 | """ |
| 263 | Testing expr_t, that allows adding constraints that are not aligned with integrator timesteps |
| 264 | """ |
| 265 | problem = placo.Problem() |
| 266 | |
| 267 | xdd = problem.add_variable(10) |
| 268 | integrator = placo.Integrator(xdd, np.array([0.0, 0.0]), 2, 0.1) |
| 269 | |
| 270 | # Adding constraint non aligned with timesteps |
| 271 | problem.add_constraint(integrator.expr_t(0.5, 0) == 1.5) |
| 272 | problem.add_constraint(integrator.expr_t(0.51, 0) == 2.5) |
| 273 | |
| 274 | for k in range(10): |
| 275 | problem.add_limit(integrator.expr(k, 0), np.array([3.0])) |
| 276 | |
| 277 | problem.add_constraint(integrator.expr_t(1.0, 0) == 0.0) |
| 278 | |
| 279 | problem.solve() |
| 280 | |
| 281 | self.assertNumpyEqual(integrator.value(0.0, 0), 0.0) |
| 282 | self.assertNumpyEqual(integrator.value(0.5, 0), 1.5) |
| 283 | self.assertNumpyEqual(integrator.value(0.51, 0), 2.5) |
| 284 | self.assertNumpyEqual(integrator.value(1.0, 0), 0.0) |
| 285 | |
| 286 | def test_integrator_zmp(self): |
| 287 | """ |
nothing calls this directly
no test coverage detected