Forum Discussion
FICO
5 years agoCommunity Manager
How do I add a user function definition to an SLP problem in C#?
I am evaluating Xpress Nonlinear Solver v.8.11.0 which I am going to use with .NET. There is a good example Polygon.cs which shows how to pass a nonlinear objective function and constraints to XSLP provided they can be defined algebraically. However, in the applications I am developing, most of the objective functions and constraints are defined algorithmically. So I need to specify a user-defined C# method and to pass its reference/delegate to XSLP. There is another good example ComplexUserFunctions.c which is doing precisely what I need, and it uses the C function XSLPadduserfunction() with the following signature:
int XPRS_CC XSLPadduserfunction(XSLPprob Prob, const char * FunctionName, int FunctionType, int nInput, int nOutput, int Options, void * FunctionPointer, void * UserContext, int * FunctionTokenId);(well-documented in the Xpress Nonlinear manual).
In my C# code, I tried to use the following:
XSLP sProb = new XSLP();
sProb.addUserFuncs(nSLPUserFunc, Type, Value);The function addUserFuncs() requires a different set of arguments, and I don't even see the user function's reference or delegate among them. Its signature is
int addUserFuncs(int nSLPUserFunc, int[] Type, double[] Value);which is obviously quite different from that in C. I couldn't find any documentation about it.
Can somebody explain to me how to pass user-defined (black-box) functions to XSLP in C#? Or show me where I can read about it (preferably with a C# example)? Can somebody help me to reproduce the ComplexUserFunctions.c example in C#?
Thanks,
Alexander
No RepliesBe the first to reply
Related Content
Related Content
How to export LP problem definition w/XpressProblem
I used to create .lp files to help debug and share problem definitions on the old XPRBprob BCL class. This was done via prob.exportProb() (on an instance of XPRBprob). For the new XpressProblem inter...2 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2CommentsAnother problem with the readln() function
Hello, I have already posted a question on this topic (https://community.fico.com/s/question/0D54w0000CcOF2iCQG/a-problem-with-the-readln-function) without, unfortunately, getting any answer. I...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2CommentsA problem with the readln function
Hello, I am having a problem with the readln() function. In fact, I want to read an instance file to start the optimization in a subsequent moment. In particular, I get the following error: Mosel:...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3Comments