def test_optimization_viewer_save(cleanup): """ Basic tests for testing the OptimizationViewer save method. """ filename = pth.join(DATA_FOLDER_PATH, "valid_sellar.toml") new_filename = pth.join(RESULTS_FOLDER_PATH, "new_valid_sellar.toml") copyfile(filename, new_filename) # Loading new file problem_configuration = FASTOADProblemConfigurator(filename) optim_viewer = OptimizationViewer() api.generate_inputs(new_filename, pth.join(DATA_FOLDER_PATH, "inputs.xml"), overwrite=True) # Load new file optim_viewer.load(problem_configuration) optim_viewer.save() optim_viewer.load(problem_configuration) # We run the problem api.optimize_problem(new_filename, overwrite=True) optim_viewer.load(problem_configuration) optim_viewer.save() optim_viewer.load(problem_configuration)
def test_optimization_viewer_load(cleanup): """ Basic tests for testing the OptimizationViewer load method. """ filename = pth.join(DATA_FOLDER_PATH, "valid_sellar.toml") # The problem has not yet been run problem_configuration = FASTOADProblemConfigurator(filename) optim_viewer = OptimizationViewer() # No input file exists with pytest.raises(FastMissingFile): optim_viewer.load(problem_configuration) api.generate_inputs(filename, pth.join(DATA_FOLDER_PATH, "inputs.xml"), overwrite=True) # Input file exist optim_viewer.load(problem_configuration) # We run the problem api.optimize_problem(filename, overwrite=True) # Load the results optim_viewer.load(problem_configuration)
def _optimize(args): """Runs driver according to provided problem file.""" try: api.optimize_problem(args.conf_file, args.force) except FastFileExistsError as exc: if _query_yes_no( 'Output file "%s" already exists. Do you want to overwrite it?' % exc.args[1]): api.optimize_problem(args.conf_file, True) else: print("Computation not run.")
def test_api_optim(cleanup): results_folder_path = pth.join(RESULTS_FOLDER_PATH, "api_optim") configuration_file_path = pth.join(results_folder_path, "oad_process.yml") # Generation of configuration file ---------------------------------------- api.generate_configuration_file(configuration_file_path, True) # Generation of inputs ---------------------------------------------------- # We get the same inputs as in tutorial notebook source_xml = pth.join( root_folder_path, "src", "fastoad", "notebooks", "01_tutorial", "data", "CeRAS01_baseline.xml", ) api.generate_inputs(configuration_file_path, source_xml, overwrite=True) # Run optim --------------------------------------------------------------- problem = api.optimize_problem(configuration_file_path, True) assert not problem.optim_failed # Check that weight-performances loop correctly converged _check_weight_performance_loop(problem) # Design Variable assert_allclose(problem["data:geometry:wing:aspect_ratio"], 14.52, atol=1e-2) # Constraint assert_allclose(problem["data:geometry:wing:span"], 44.88, atol=1e-2) # Objective assert_allclose(problem["data:mission:sizing:needed_block_fuel"], 18900.0, atol=1)