Can I change the working directory in a file more than once?

include is relative to the directory of the current file, not relative to the current working directory.

So you can do:

include("../../opt_problems/unconstrained_problems.jl")
include("../../opt_problems/regression_problems.jl")

with no cd and no @__DIR__ at all.

2 Likes