Skip to content

Honor the objective weight y0 in cshj, chjprod and cdhj for problems without constraints - #117

Merged
nimgould merged 2 commits into
ralna:masterfrom
cvanaret:fix_objective_weight
Nov 2, 2026
Merged

nimgould merged 2 commits into
ralna:masterfrom
cvanaret:fix_objective_weight

Conversation

@cvanaret

@cvanaret cvanaret commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

When a problem has no constraints (data%numcon == 0), cshj and cdhj assemble the Lagrangian Hessian with the unweighted group scales data%GSCALE. chjprod forms the Hessian-vector product the same way. As a result y0 is ignored, and the routines return ∇²f instead of y0 ∇²f.

Solvers that pass y0 ≠ 1 therefore receive a Hessian that is inconsistent with the scaled gradient. Examples are solvers that scale the objective (such as gradient-based scaling in IPOPT or Uno) and solvers that weight the objective during feasibility restoration. With scaling, the Newton steps come out shortened by the scaling factor.

@amontoison
amontoison requested a review from nimgould November 1, 2026 00:42
@amontoison amontoison added the bug Something isn't working label Nov 1, 2026
@nimgould

nimgould commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

My only concern is that the c* cutest functions are for constrained problems, but I believe that csetup, etc, does
the right thing when m = 0. Did you check?

I would also add

IF ( data%numcon == 0 .AND. y0 /= 1.0_rp_ )

to avoid unnecessary multiplications.

@cvanaret

cvanaret commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

As far as I can tell, csetup does the right thing for unconstrained problems:

  • m starts at 0 and is not incremented because there is no constraint group
  • it marks the groups as objective group (KNDOFC = 0)
  • it prints The problem has no general constraints. Other tools may be preferable
  • it sets data%numcon = m (= 0)

cshj, chjprod, and cdhj are then called with data and y0. It makes sense to go through csetup for unconstrained problems, because usetup has no objective multiplier y0.

@nimgould

nimgould commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

OK, this looks good to go. Thanks

@nimgould
nimgould merged commit acff7e0 into ralna:master Nov 2, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants