Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output wall clock time per iteration? #178

Closed
ghost opened this issue Aug 1, 2019 · 16 comments
Closed

Output wall clock time per iteration? #178

ghost opened this issue Aug 1, 2019 · 16 comments

Comments

@ghost
Copy link

ghost commented Aug 1, 2019

Hello,

I would like to know if there is an option to output the elapsed wall clock time per iteration? If there is no such function, i would like to modify the source code myself to add it. Can you point me to the file which i would have to edit?

@blegat
Copy link
Member

blegat commented Aug 1, 2019

It is done in #170

@ghost
Copy link
Author

ghost commented Aug 1, 2019

Nice, also thanks for your fast answer :)

Do i have to wait until the commit is merged or can i possibly use the branch with this commit right now? I am also thinking of modifying the source code until this feature is added.

Currently, when i try to use the branch with the commit, I get:
grafik

@blegat
Copy link
Member

blegat commented Aug 1, 2019

You need use the master branch of MathOptInterface and this branch of JuMP: jump-dev/JuMP.jl#2003 if you want to use the branch of #170

@ghost
Copy link
Author

ghost commented Aug 5, 2019

Thank you. It is working, but not for my use case (with PowerModels.jl). I think this issue can be closed for now, if you don't want to leave it open for further discussions.
grafik

@blegat blegat closed this as completed Aug 5, 2019
@jchen975
Copy link

jchen975 commented Aug 18, 2019

Thank you. It is working, but not for my use case (with PowerModels.jl). I think this issue can be closed for now, if you don't want to leave it open for further discussions.
grafik

Hi @snapdeb, were you able to resolve this issue on PowerModels.jl? I'm doing a large number of run_ac_pf() in parallel and I would like to know each run's number of iterations and each iteration's elapsed time. It would be a pain to parse the output file because of the From worker x outputs and all the other information. Any advice is appreciated!

@ghost
Copy link

ghost commented Aug 19, 2019

Hi @jchen975,

The following screenshot shows the current state. The Ipopt#master branch is needed since the wall clock time per iteration is included there. Also i chose the PowerModels#master branch since it has fever unsatisfiable requirements (since it is more up-to-date).
grafik
The problem is that Ipopt#master depends on MathOptInterface v0.9.0, while PowerModels depends on MathOptInterface v0.8.0. Thus we need to wait until PowerModels receives a new update, or assist in the development if at all possible.

@jchen975
Copy link

@lschmelting Hey, thanks for your reply and opening the issue there. I suppose before that is updated, knowing the number of iterations in each run_ac_pf will suffice. Do you know if there is a function for that? I'm still pretty new to using JuliaOpt, but does BarrierIterations() have anything to do with what I want?

Alternatively, I would have to parse the Ipopt output, but I really don't want to do that if there's something I can use directly.

@ghost
Copy link

ghost commented Aug 20, 2019

When you call JuMP you should use the default print_level=5, which if I remember correctly, includes the number of iterations and some info for each iteration. Some additonal timing statistics are shown when using print_timing_statistics="yes". Additionally, you can specify an output_file.

JuMP.with_optimizer(Ipopt.Optimizer, print_level=5, print_timing_statistics="yes", output_file="C:\\Users\\lschmelting\\workspace\\Ipopt_Output")

@jchen975
Copy link

When you call JuMP you should use the default print_level=5, which if I remember correctly, includes the number of iterations and some info for each iteration. Some additonal timing statistics are shown when using print_timing_statistics="yes". Additionally, you can specify an output_file.

JuMP.with_optimizer(Ipopt.Optimizer, print_level=5, print_timing_statistics="yes", output_file="C:\\Users\\lschmelting\\workspace\\Ipopt_Output")

Yes, and actually setting print_level=3 prints the number of iterations without further details, which I think is what I need for now. However, specifying an output file still requires further inspection or parsing to find the itr # information. Is there a better way to do that directly from PowerModels/JuMP/Ipopt?

@ghost
Copy link

ghost commented Aug 21, 2019

I don't know of a better way, maybe someone else does.

@jchen975
Copy link

This short python script does the job. It's actually easier than I expected, but it would be nice to have a function to get #itr instead of having to parse the output file.

filepath = "./test.log"  # change this to the directory containing the output.log
key = "Number of Iterations...."

itr = []
with open(filepath) as fp:
	s = fp.readline()
	while s:
		l = [ss.strip() for ss in s.split(":")]
		if len(l) >= 2 and l[-2] == key:
			itr.append(int(l[-1]))
		s = fp.readline()

@mlubin
Copy link
Member

mlubin commented Aug 22, 2019

Unless you can find somewhere to extract this information from Ipopt's API, there's not really much we can do on the Julia side.

@ghost
Copy link

ghost commented Aug 27, 2019

wall_clock_time_per_iteration.txt

@jchen975: PowerModels is again usable with the Ipopt master branch: add Ipopt#master PowerModels#master.

I don't see a wall clock time per iteration output, though.
I use Ipopt like this: ipopt_solver = JuMP.with_optimizer(Ipopt.Optimizer, print_level=5, print_timing_statistics="yes", output_file="C:\\Users\\lschmelting\\workspace\\test").

Any hints?

@jchen975
Copy link

@lschmelting Sorry, I have no clue either. @ccoffrin could you help with this?

@ccoffrin
Copy link
Contributor

I am not aware of an Ipopt feature that will print the time-per iteration, any insights @snapdeb, @blegat?

Another option is to inquire about this on the coin-or mailing list, e.g. see https://www.coin-or.org/. Once the required feature at the C++ level is clear we can see how to make it accessible from MOI/JuMP.

For what it is worth PowerModels#master is now tested with Ipopt.jl v0.6, which includes the udates from #170.

@dpo
Copy link
Contributor

dpo commented Oct 19, 2019

In the mean time, you could pass a callback and measure time yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants