@@ -289,50 +289,50 @@ TEST(IdeSecir, checkInitializations)
289289 contact_matrix[0 ] = mio::ContactMatrix (Eigen::MatrixXd::Constant (1 , 1 , 0 ));
290290 parameters.get <mio::isecir::ContactPatterns>() = mio::UncertainContactMatrix (contact_matrix);
291291
292- mio::TimeSeries<ScalarType> init_copy3 (init);
293- mio::isecir::Model model3 (std::move (init_copy3 ), N, deaths, 0 , std::move (parameters));
292+ mio::TimeSeries<ScalarType> init_copy2 (init);
293+ mio::isecir::Model model2 (std::move (init_copy2 ), N, deaths, 0 , std::move (parameters));
294294
295- model3 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 5000 ;
296- model3 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 0 ;
295+ model2 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 5000 ;
296+ model2 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 0 ;
297297
298298 // Carry out simulation.
299- mio::isecir::Simulation sim3 (model3 , 0 , dt);
300- sim3 .advance (tmax);
299+ mio::isecir::Simulation sim2 (model2 , 0 , dt);
300+ sim2 .advance (tmax);
301301
302302 // Verify that the expected initialization method was used.
303- EXPECT_EQ (2 , sim3 .get_model ().get_initialization_method ());
303+ EXPECT_EQ (2 , sim2 .get_model ().get_initialization_method ());
304304
305305 // --- Case with R.
306- mio::TimeSeries<ScalarType> init_copy4 (init);
307- mio::isecir::Model model4 (std::move (init_copy4 ), N, deaths, 0 , std::move (parameters));
306+ mio::TimeSeries<ScalarType> init_copy3 (init);
307+ mio::isecir::Model model3 (std::move (init_copy3 ), N, deaths, 0 , std::move (parameters));
308308
309- model4 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 0 ;
310- model4 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 1000 ;
309+ model3 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 0 ;
310+ model3 .m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 1000 ;
311311
312312 // Carry out simulation.
313- mio::isecir::Simulation sim4 (model4 , 0 , dt);
314- sim4 .advance (tmax);
313+ mio::isecir::Simulation sim3 (model3 , 0 , dt);
314+ sim3 .advance (tmax);
315315
316316 // Verify that the expected initialization method was used.
317- EXPECT_EQ (3 , sim4 .get_model ().get_initialization_method ());
317+ EXPECT_EQ (3 , sim3 .get_model ().get_initialization_method ());
318318
319319 // --- Case with forceofinfection.
320- mio::TimeSeries<ScalarType> init_copy2 (init);
321- mio::isecir::Model model2 (std::move (init_copy2 ), N, deaths, 0 );
320+ mio::TimeSeries<ScalarType> init_copy4 (init);
321+ mio::isecir::Model model4 (std::move (init_copy4 ), N, deaths, 0 );
322322
323323 // Carry out simulation.
324- mio::isecir::Simulation sim2 (model2 , 0 , dt);
325- sim2 .advance (tmax);
324+ mio::isecir::Simulation sim4 (model4 , 0 , dt);
325+ sim4 .advance (tmax);
326326
327327 // Verify that the expected initialization method was used.
328- EXPECT_EQ (4 , sim2 .get_model ().get_initialization_method ());
328+ EXPECT_EQ (4 , sim4 .get_model ().get_initialization_method ());
329329
330330 // --- Case without fitting initialization method.
331- // Deactivate temporarily log output for next test. Error is expected here.
331+ // Deactivate temporarily log output for next tests. Errors are expected here.
332332 mio::set_log_level (mio::LogLevel::off);
333333
334- // Here we do not need a copy of init as this is the last use of the vector. We can apply move directly.
335- mio::isecir::Model model5 (std::move (init ), N, deaths, 0 , std::move (parameters));
334+ mio::TimeSeries<ScalarType> init_copy5 ( init);
335+ mio::isecir::Model model5 (std::move (init_copy5 ), N, deaths, 0 , std::move (parameters));
336336
337337 model5.m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 0 ;
338338 model5.m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 0 ;
@@ -344,6 +344,22 @@ TEST(IdeSecir, checkInitializations)
344344 // Verify that initialization was not possible with one of the models methods.
345345 EXPECT_EQ (-1 , sim5.get_model ().get_initialization_method ());
346346
347+ // --- Test with negative number of deaths.
348+ deaths = -10 ;
349+
350+ // Here we do not need a copy of init as this is the last use of the vector. We can apply move directly.
351+ mio::isecir::Model model6 (std::move (init), N, deaths, 0 , std::move (parameters));
352+
353+ model6.m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Susceptible] = 0 ;
354+ model6.m_populations .get_last_value ()[(Eigen::Index)mio::isecir::InfectionState::Recovered] = 0 ;
355+
356+ // Carry out simulation.
357+ mio::isecir::Simulation sim6 (model6, 0 , dt);
358+ sim6.advance (tmax);
359+
360+ // Verify that initialization was possible but the result is not appropriate.
361+ EXPECT_EQ (-2 , sim6.get_model ().get_initialization_method ());
362+
347363 // Reactive log output.
348364 mio::set_log_level (mio::LogLevel::warn);
349365}
@@ -383,8 +399,7 @@ TEST(IdeSecir, testModelConstraints)
383399 auto constraint_check = model_wrong_size.check_constraints (dt);
384400 EXPECT_TRUE (constraint_check);
385401
386- // --- Test with negative number of deaths.
387- deaths = -10 ;
402+ // --- Test with too few time points.
388403 // Create TimeSeries with num_transitions elements.
389404 mio::TimeSeries<ScalarType> init (num_transitions);
390405 // Add time points for initialization of transitions.
@@ -395,16 +410,6 @@ TEST(IdeSecir, testModelConstraints)
395410 init.add_time_point (init.get_last_time () + dt, vec_init);
396411 }
397412
398- // Initialize a model.
399- mio::TimeSeries<ScalarType> init_copy (init);
400- mio::isecir::Model model_negative_deaths (std::move (init_copy), N, deaths);
401-
402- // Return true for negative entry in m_populations.
403- constraint_check = model_negative_deaths.check_constraints (dt);
404- EXPECT_TRUE (constraint_check);
405-
406- // --- Test with too few time points.
407- deaths = 10 ;
408413 // Initialize a model.
409414 mio::isecir::Model model_few_timepoints (std::move (init), N, deaths);
410415
0 commit comments