-
Notifications
You must be signed in to change notification settings - Fork 307
Open
Description
Hi there
Just in case you're interested, and you want to reference it in the documentation or somewhere else: I published a .NET interface for IPOPT under the Apache-2.0 license.
Source code: https://github.com/sfiruch/ipopt-net.
NuGet package: https://www.nuget.org/packages/ipopt-net/
In addition to the low-level C interface, it also provides a modelling API with automatic differentiation on top:
using IpoptNet.Modelling;
// Create a model
var model = new Model();
// Configure IPOPT (optional)
model.Options.LinearSolver = LinearSolver.PardisoMkl;
model.Options.HessianApproximation = HessianApproximation.LimitedMemory;
// Add variables with bounds and optional initial guesses
var x = model.AddVariable(1, 5);
var y = model.AddVariable(1, 5) { Start = 3.7 };
var z = model.AddVariable(1, 5);
var w = model.AddVariable(1, 5);
// Set objective: minimize x*w*(x+y+z) + z (expressions can be built incrementally)
var expr = x * (x + y + z);
expr *= w;
model.SetObjective(expr + z);
// Add constraints
model.AddConstraint(x * y * z * w >= 25);
model.AddConstraint(x*x + y*y + z*z + w*w == 40);
// Solve
var result = model.Solve();
if (result.Status == ApplicationReturnStatus.SolveSucceeded)
{
Console.WriteLine($"x = {result.Solution[x]:F3}");
Console.WriteLine($"y = {result.Solution[y]:F3}");
Console.WriteLine($"z = {result.Solution[z]:F3}");
Console.WriteLine($"w = {result.Solution[w]:F3}");
Console.WriteLine($"Objective = {result.ObjectiveValue:F3}");
}I'll try to keep the package up to date. If there will ever be official amd64 Linux binaries, I'll happily include those too.
Best regards
Simon
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels