Dear Antonin,
The name of the Pareto file is interpreted when the AssistedSpecification object is created. Therefore, if the object is created before changing the working directory, Biogeme will look for the Pareto file relative to the original directory.
The simplest solution is to provide an absolute path when constructing the object:
output_directory = output_directory.resolve()
pareto_file = output_directory / "my_model.pareto"
assisted_specification = AssistedSpecification(
biogeme_object=the_biogeme,
multi_objectives=loglikelihood_dimension,
pareto_file_name=str(pareto_file),
)
You can then run it from any working directory:
non_dominated_models = assisted_specification.run()
Alternatively, change directory before constructing AssistedSpecification, but using an absolute path is safer and avoids global changes to the process working directory.
If you still want to change directory for the other output files, make sure that it is restored even if estimation raises an exception:
from contextlib import contextmanager
from pathlib import Path
import os
@contextmanager
def working_directory(directory: Path):
previous_directory = Path.cwd()
os.chdir(directory)
try:
yield
finally:
os.chdir(previous_directory)
with working_directory(output_directory):
non_dominated_models = assisted_specification.run()
But the Pareto filename should still preferably be absolute.
Best regards,
Michel
> --
> You received this message because you are subscribed to the Google Groups "Biogeme" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
biogeme+u...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/biogeme/a4b8aa63-1eae-48b1-8511-95d0848f3e4cn%40googlegroups.com.
Michel Bierlaire
Transport and Mobility Laboratory
School of Architecture, Civil and Environmental Engineering
EPFL - Ecole Polytechnique Fédérale de Lausanne
http://transp-or.epfl.ch
http://people.epfl.ch/michel.bierlaire