Skip to content

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Jul 12, 2025

This PR implements comprehensive validation of evaluation counters by comparing CUTEst.jl's internal counter tracking with CUTEst's native reporting functions.

  • test/test_counters.jl: Complete test suite for counter validation
  • get_cutest_counters(): Utility function that extracts counters from CUTEst's native reporting functions
  • test_counter_validation(): Main test function with separate validation for unconstrained and constrained problems

Closes #278
Closes #465

arnavk23 and others added 6 commits July 11, 2025 11:35
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Potential fix for code scanning alert no. 8: Workflow does not contain permissions
Copy link
Member

@tmigot tmigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! I made a couple of comments.

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.95%. Comparing base (f2ad6a4) to head (d7af525).
⚠️ Report is 165 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #463       +/-   ##
===========================================
- Coverage   89.11%   73.95%   -15.16%     
===========================================
  Files           5        7        +2     
  Lines         790     1678      +888     
===========================================
+ Hits          704     1241      +537     
- Misses         86      437      +351     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

arnavk23 and others added 4 commits July 14, 2025 19:03
Co-authored-by: Tangi Migot <tangi.migot@gmail.com>
Co-authored-by: Tangi Migot <tangi.migot@gmail.com>
Co-authored-by: Tangi Migot <tangi.migot@gmail.com>
@arnavk23 arnavk23 requested a review from tmigot July 15, 2025 03:01
Comment on lines +160 to +174
# CUTEst's constrained problem implementation has specific counting behavior
@test julia_increments.neval_obj == 1
@test cutest_increments.neval_obj == 0 # CUTEst doesn't count obj in constrained setup

@test julia_increments.neval_cons == 1
@test cutest_increments.neval_cons == 2 # CUTEst counts 1 extra constraint call

@test julia_increments.neval_jac == 1
@test cutest_increments.neval_jac == 2 # CUTEst counts 1 extra jacobian call

@test julia_increments.neval_hess == 1
@test cutest_increments.neval_hess == 2 # CUTEst counts 1 extra hessian call

@test julia_increments.neval_jprod == 1
@test cutest_increments.neval_jprod == 2 # CUTEst counts 1 extra jprod call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amontoison Any idea why we have these differences?

Copy link
Contributor Author

@arnavk23 arnavk23 Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The differences between the NLPModels.jl counters and CUTEst’s native counters come from how each system tracks function evaluations internally.

  • NLPModels.jl increments its counters every time a Julia wrapper function is called, so it reflects exactly what the user code requests.
  • CUTEst, on the other hand, sometimes counts extra internal calls (for things like Hessian, Jacobian, or constraint evaluations) or may skip counting certain evaluations, depending on whether the problem is constrained or unconstrained and how its Fortran backend is implemented.
  • For example, in constrained problems, CUTEst might not increment the objective counter, or it might count an extra call for Jacobian or constraint evaluations due to its internal logic. These differences are expected and are documented in the test file.

arnavk23 and others added 2 commits July 27, 2025 19:20
Co-authored-by: Tangi Migot <tangi.migot@gmail.com>
@arnavk23 arnavk23 requested a review from tmigot July 27, 2025 15:31
@tmigot tmigot requested a review from amontoison July 27, 2025 15:44
    test_counters.jl
"""
neval_hprod = Int(calls[4]),
neval_cons = Int(calls[5]),
neval_jac = Int(calls[6]),
neval_jprod = Int(calls[7])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arnavk23 A counter for jtprod is missing.
Otherwise LGTM 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay @arnavk23, I was working on many projects recently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amontoison Added jtprod.

@arnavk23 arnavk23 requested a review from amontoison August 31, 2025 22:13
@amontoison amontoison merged commit a34667d into JuliaSmoothOptimizers:main Sep 7, 2025
19 of 20 checks passed
@amontoison
Copy link
Member

Thank you @arnavk23 !

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test/test_counters.jl missing counter fields Check eval counters against those from CUTEst

3 participants