cureos / csipopt Goto Github PK
View Code? Open in Web Editor NEW.NET interface to Ipopt non-linear optimizer
Home Page: http://code.google.com/p/csipopt/
License: Eclipse Public License 1.0
.NET interface to Ipopt non-linear optimizer
Home Page: http://code.google.com/p/csipopt/
License: Eclipse Public License 1.0
Recently I'd begin using IPOPT (c++), run an example and everything works good.
I'd tried to make the same excersise in C# and use CSIOPT, everything works good until I cannot found the C# implementation of finalize_solution (the one thta populate all the results in arrays) calling (set_solver_status, set_objective_value, set_primal_solution and set_dual_solution).
On my understand in c++ this is done automatically when solve it,
/** This method is called when the algorithm is complete so the TNLP can
* store/write the solution */
virtual void finalize_solution(SolverReturn status, Index n,
const Number *x, const Number *z_L,
const Number *z_U, Index m, const Number *g,
const Number *lambda, Number obj_value,
const IpoptData *ip_data,
IpoptCalculatedQuantities *ip_cq);
How can achive this? there is another method, the only result was the .out file with the IPOPT outputs
Thanks
Rename Ipopt
instance partial class to IpoptProblem
and removed sealed
directive.
Implement additional IpoptProblem
constructor that takes native delegates as arguments.
Make Dispose(bool)
method virtual protected
to facilitate subclassing.
Have problem classes like HS071 inherit IpoptProblem
.
Move static interop methods and delegates to static class IpoptAdapter
.
Remove SetIntermediateCallback
method from IpoptProblem
; have inheriting classes setting m_intermediate
in the constructor instead.
Consider making SetScaling
method a Scaling
property with a setter instead.
For completeness, it should be possible to subclass IpoptProblem using "managed" callback functions as well.
System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Cureos.Numerics.IpoptAdapter.IpoptSolve(IntPtr ipopt_problem, Double[] x, Double[] g, ref Double obj_val, Double[] mult_g, Double[] mult_x_L, Double[] mult_x_U, IntPtr user_data)
at Cureos.Numerics.IpoptProblem.SolveProblem(Double[] x, ref Double obj_val, Double[] g, Double[] mult_g, Double[] mult_x_L, Double[] mult_x_U) in IpoptProblem.cs: line 574
at Cureos.Numerics.HS040NativeTests.SolveProblem_ExactHessian_NumberOfIterationsLessThanOrEqualToHessianApprox() in HS040NativeTests.cs: line 94
I am having a memory corruption issue while using CSIPOPT in my code. I've boiled it down into a project that demonstrates the issue. It is a simple optimization problem. The issue occurs when I run it over and over in a loop. If there is some way to transfer the example problem, I'll be more than happy to do that. I linked against the pre-built 1.0.0 binaries. The stack trace is as follows:
at Cureos.Numerics.IpoptAdapter.FreeIpoptProblem(IntPtr ipopt_problem)
at Cureos.Numerics.IpoptProblem.Dispose(Boolean disposing) in C:\Users\anders.CUREOS\Documents\Visual Studio 2010\Projects\csipopt\src\IpoptProblem.cs:line 658
Any help would be appreciated.
Thanks!
John
It is not sufficient to use the "classic" csipopt API with Mono any more. In the first call to a function delegate, the following exception is thrown:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at string.memcpy4 (byte*,byte*,int) <0x00018> at string.memcpy (byte*,byte*,int) <0x000b7> at (wrapper native-to-managed) Cureos.Numerics.IpoptProblem/JacobianEvaluator.Ev aluate (int,intptr,Cureos.Numerics.IpoptBoolType,int,int,intptr,intptr,intptr,in tptr) <0x00087> at (wrapper managed-to-native) Cureos.Numerics.IpoptAdapter.IpoptSolve (intptr,d ouble[],double[],double&,double[],double[],double[],intptr) <0x00003> at Cureos.Numerics.IpoptProblem.SolveProblem (double[],double&,double[],double[] ,double[],double[]) <0x0004f> at hs071_cs.Program.Main (string[]) <0x002af>
This happens regardless of which executable is being run with the Mono runtime, mcs or Visual C# compiled.
On the other hand, when running an mcs compiled executable using the regular .NET runtime, the optimization problem is successfully solved.
I am having trouble accessing some of the links, for instance https://github.com/cureos/csipopt/blob/master/nlp/HS071.cs
Excerpt from e-mail:
I am trying to test it with visual studio 2015 but I get an error when I am trying to build the cureos.numerics VS solution. I guess that there is a path problem since I did not find where to link the header files coming from the precompiled IPOPT library (from the version Ipopt-3.11.0-Win32-Win64-dll, the one you recommend). The only thing I did until now was to copy the dll in files
C:...\Ipopt-3.11.0-Win32-Win64-dll\lib\x64\ReleaseMKL\
to
C:...\csipopt-master\csipopt-master\Cureos.Numerics
The error message I get when trying to build the project is
Error occurred while restoring NuGet packages: An error occurred while reading file 'C:\IPOPTDDL\csipopt-master\csipopt-master\Cureos.Numerics\Tests.Cureos.Numerics\packages.config': There are duplicate packages: NUnit
1>------ Rebuild All started: Project: Cureos.Numerics, Configuration: Debug Any CPU ------
1>CSC : warning CS1668: Invalid search path 'C:\Program Files\Artelys\Knitro 10.1.1\lib' specified in 'LIB environment variable' -- 'directory does not exist'
1> Cureos.Numerics -> C:\IPOPTDDL\csipopt-master\csipopt-master\Cureos.Numerics\Cureos.Numerics\bin\Debug\Cureos.Numerics.dll
2>------ Rebuild All started: Project: Tests.Cureos.Numerics, Configuration: Debug x64 ------
2> All packages listed in packages.config are already installed.
2>CSC : warning CS1668: Invalid search path 'C:\Program Files\Artelys\Knitro 10.1.1\lib' specified in 'LIB environment variable' -- 'directory does not exist'
2> Tests.Cureos.Numerics -> C:\IPOPTDDL\csipopt-master\csipopt-master\Cureos.Numerics\Tests.Cureos.Numerics\bin\x64\Debug\Tests.Cureos.Numerics.dll
2> File not found - .dll
2> 0 File(s) copied
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4713,5): error MSB3073: The command "xcopy /y /q /r /k "C:\IPOPTDDL\csipopt-master\csipopt-master\Cureos.Numerics....\Ipopt\Lib\x64\ReleaseMKL*.dll" "C:\IPOPTDDL\csipopt-master\csipopt-master\Cureos.Numerics\Tests.Cureos.Numerics\bin\x64\Debug*."" exited with code 4.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Could you help me to solve this error?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.