Skip to content

Differentiation of problems with Almost Locally Solved termination status #336

Description

@awest32

DiffOpt seems to not suppoer problems with the termination status Almost Locally Solved. Below is a minimum working example.

using JuMP
using Ipopt
using DiffOpt

# Create differentiable model with loose tolerances
diff_optimizer = optimizer_with_attributes(
    Ipopt.Optimizer,
    "print_level" => 3,
    "tol" => 1e-2,
    "acceptable_tol" => 1e-1,
    "max_iter" => 5,
    "acceptable_iter" => 2
)

model = Model(() -> DiffOpt.diff_optimizer(diff_optimizer))

# Decision variables
@variable(model, x >= 0)
@variable(model, y >= 0)

# Parameters (weights in objective)
w = [0.1, 0.1]  # Initial parameter values
weight = w
weight = JuMP.@variable(
    model,
    [j in keys(w)] in MOI.Parameter(w[j]),
    base_name = "weight")

@constraint(model, x + y >= 10)
@constraint(model, 2x + y >= 15)

@objective(model, Min, weight[1]*x + weight[2]*y)

optimize!(model)

println("\nStatus: $(termination_status(model))")

for (i, key) in enumerate(keys(weight))
    perturbation = i
    DiffOpt.set_forward_parameter(model, weight[key], perturbation)
end

# Solve perturbed problem
optimize!(model)

# Compute forward derivatives
DiffOpt.forward_differentiate!(model)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions