Skip to content

Commit e98e565

Browse files
authored
Fix/obj gap (#7)
* fix: objective_gap calculation * fix: constraint_bound_norm=0 bug when bound_objective_rescaling=false
1 parent 3a6d5b1 commit e98e565

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cupdlpx/solver.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static void initialize_step_size_and_primal_weight(pdhg_solver_state_t *state, c
563563
}
564564
else
565565
{
566-
state->primal_weight = state->objective_vector_norm / state->constraint_bound_norm;
566+
state->primal_weight = (state->objective_vector_norm + 1.0) / (state->constraint_bound_norm + 1.0);
567567
}
568568
state->best_primal_weight = state->primal_weight;
569569
}

cupdlpx/utils.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ void compute_residual(pdhg_solver_state_t *state)
561561

562562
state->relative_primal_residual = state->absolute_primal_residual / (1.0 + state->constraint_bound_norm);
563563
state->relative_dual_residual = state->absolute_dual_residual / (1.0 + state->objective_vector_norm);
564-
state->relative_objective_gap = fabs(state->primal_objective_value - state->dual_objective_value) /
565-
(1.0 + fabs(state->primal_objective_value) + fabs(state->dual_objective_value));
564+
state->objective_gap = fabs(state->primal_objective_value - state->dual_objective_value);
565+
state->relative_objective_gap = state->objective_gap / (1.0 + fabs(state->primal_objective_value) + fabs(state->dual_objective_value));
566566
}
567567

568568
void compute_infeasibility_information(pdhg_solver_state_t *state)

0 commit comments

Comments
 (0)