GithubHelp home page GithubHelp logo

Comments (5)

jajhall avatar jajhall commented on July 20, 2024

Oops, yes, I was trying to put a CRTL-C handler into HiGHS but gave up, and failed to remove the development code (Lines 52 onwards in lp_data/Highs.cpp)

void highsSignalHandler(int signum) {
// std::cout << "Interrupt signal (" << signum << ") received.\n";
exit(signum);
}
Highs::Highs() { signal(SIGINT, highsSignalHandler); }

Since there is not (yet) anything in the HiGHS Fortran API to handle callbacks, do I infer from the following that you had to wrote something yourself and had to get around the fact that in HighsCallbackDataOut (see lp_data/HighsCallbackStruct.h) the pointer to the values of the solution is not on an 8-byte boundary - since an int, two HighsInt (which can be 4 or 8 bytes) and an int64_t constitute an odd number of 4-byte words. I can get around this by making double* mip_solution the first member of the HighsCallbackDataOut struct. That scalar doubles won't be on 8-byte boundaries presumably has little overhead.

Assuming that you wrote your own Fortran API to handle callbacks, could you share it with me since I wouldn't know how to write it.

The callback to retrieve the variable-length double 1D-array mip_solution(*) works well except that I noticed an arbitrary five (5) element offset in order to properly align the C mip_solution() vector into the Fortran mip_solution() i.e., mip_solution(1+5:n+5) where "n" is the known length of variables. Otherwise, the variable solution data for each integer-feasible solution is received properly including the mix of reals and integers placed before mip_solution().

from highs.

jeffreydeankelly2 avatar jeffreydeankelly2 commented on July 20, 2024

from highs.

jajhall avatar jajhall commented on July 20, 2024

Thanks for letting me know about the CRTL-C signal handler - I look forward
to it being removed in your next release :-)

I've asked the two other folk with whom I've communicated regarding the CRTL-C signal handler, just out of politeness, as removing it would, technically, break the API

Technically speaking, all C to Fortran API's seem to be redundant given
standard Fortran's C Interoperability capability. Hence I never use these
API's supplied by 3rd C/C++ based solvers as they are usually out-of-date
and incomplete as well.

That's interesting to know. Our Fortran API can certainly be classed as "out-of-date and incomplete". I'll still keep it, as it does no harm, but add a comment to the effect that it's out-of-date and incomplete, and that folk should exploit standard Fortran's C Interoperability capability.

The way all of the other MIP callbacks are implemented is to allow the user
to call for example your Highs_getSolution() routine (or the like) to
retrieve the MIP improving solutions inside the callback routine.

This wouldn't work in HiGHS, as no MIP solver data can be reached via the Highs C++ API. Indeed, if a user's callback function were to start calling methods in the instance of the Highs class (by passing a pointer to it via the void* user_data parameter) then all sorts of chaos could ensue! I should add code to the Highs C++ API to ensure that all methods give an immediate error return!

Thanks for the Fortran callback function. I'll add it to examples/call_highs_from_fortran.f90.

I can get around this by making double* mip_solution the first member of
the HighsCallbackDataOut struct. That scalar doubles won't be on 8-byte
boundaries presumably has little overhead.

That may work but I am not sure if the other appended integers and doubles
will be affected with offsets in a similar way when receiving their values
in Fortran.

Ah, so they may be wrong, not just slower to access. I'm forgetting my Fortran implications!

from highs.

jeffreydeankelly2 avatar jeffreydeankelly2 commented on July 20, 2024

from highs.

jajhall avatar jajhall commented on July 20, 2024

I'm trying to call the Highs instance from a call-back in check/TestCallbacks.cpp, but don't see how to pass and use the Highs instance via the void* pointer in highs-callback-no-highs-call in check/TestCallbacks.cpp

See branch fix-1523-latest

from highs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.