Forum Discussion
FICO
3 years agoCommunity Manager
Const correctness and thread safety in the C-API
How do I know :
- Which functions can be considered const i.e leave the XPRSprob in an unaltered state ?
- Which functions are thread safe ? (I am in particular interested in knowing if XPRSbtran and XPRSftran can be called from multiple threads)
3 Replies
- FICOCommunity Manager
Hi Bo,
in general our internal btran/ftran functions are thread-safe and are already called from multiple threads during our parallel dual/crossover. Unfortunately, it appears that the XPRSbtran and XPRSftran functions are not due to the way the provided solution is stored before calling the actual btran/ftran, but if this would be important for you, it should be possible to add new functions for this that would be thread-safe.
Any specific functions you are wondering about with regards to the const? In general most of the get functions should normally leave the XPRSprob unchanged, while the solve functions as well as any add/set functions would not, but if you are wondering about any specific ones, I can double check in the code.
Strictly speaking there is also the issue that even the get-methods might store the last error code within the XPRSprob if the input arguments were incorrect so that it can be checked via XPRSgetlasterror, so in that regard pretty much no function could be considered truly "const".
Best,
Tristan
- FICOCommunity Manager
Hi Tristan,
Thank you for the clarification. I would have expected a set of functions to be marked as const by having a XPRSConstprob definition as input for these cases. That's why I asked.
I will work with what we have then :-)
- FICOCommunity Manager
Hi Bo,
note that a prob does not only describe the problem to be solved. It also describes the environment/context in which the problem is solved. In particular, it carries the last error code and last error message (see XPRSgetlaserror, for example). Since this may change for any XPRS function, the prob itself can never be const.
Once could probably introduce a notion of "conceptually constant" but that would not be very clear cut and would also not be something that one would enforce by using the `const` keyword.
Related Content
Related Content
Parameter Threads
Hi, I'm using Fico Xpress and I have a question about the parameter THREADS. According to the documentation, THREADS > 0 means the "number of threads to use". Let suppose THREADS = 4. In this ca...7 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2Comments__lll_lock_wait allowing only one thread to work
I am calling the XPRESS optimizer from a multithreaded Pascal application and having performance issues with the solver. While the program is multithreaded, all but one of the threads are sleeping a...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum21 unread comments21 unread1View0likes21CommentsWhat is the correct syntax of the function branchobj.addrows?
I am implementing a branch-and-bound algorithm in Python using the Xpress package. In this algorithm, I create multiple child nodes with different added constraints. I use the addcbchgbranchobject c...2 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3Comments