88#include < mutex>
99#include < stack>
1010#include < stdexcept>
11+ #ifndef _WIN32
1112#include < unistd.h>
13+ #endif
1214
1315namespace xpress
1416{
@@ -356,7 +358,7 @@ XPRSprob Model::_toggle_model_mode(XPRSprob model)
356358{
357359 if (m_mode == XPRESS_MODEL_MODE::MAIN)
358360 {
359- m_mode = XPRESS_MODEL_MODE::CALLBACK ;
361+ m_mode = XPRESS_MODEL_MODE::CALLBACK_ ;
360362 }
361363 else
362364 {
@@ -381,7 +383,7 @@ catch (std::exception e)
381383void Model::close ()
382384{
383385 // In CALLBACK mode we cannot destroy the problem, we release the unique_ptr instead
384- if (m_mode == XPRESS_MODEL_MODE::CALLBACK )
386+ if (m_mode == XPRESS_MODEL_MODE::CALLBACK_ )
385387 {
386388 [[maybe_unused]] auto _ = m_model.release ();
387389 }
@@ -557,7 +559,7 @@ std::string Model::pprint_variable(VariableIndex variable)
557559
558560std::string Model::_get_entity_name (int etype, int eidx)
559561{
560- _check_expected_mode (XPRESS_MODEL_MODE::MAIN);
562+ _check_expected_mode (XPRESS_MODEL_MODE::MAIN);
561563 _ensure_postsolved ();
562564
563565 int req_size = {};
@@ -2168,12 +2170,12 @@ void Model::_ensure_postsolved()
21682170
21692171void Model::_check_expected_mode (XPRESS_MODEL_MODE mode)
21702172{
2171- if (mode == XPRESS_MODEL_MODE::MAIN && m_mode == XPRESS_MODEL_MODE::CALLBACK )
2173+ if (mode == XPRESS_MODEL_MODE::MAIN && m_mode == XPRESS_MODEL_MODE::CALLBACK_ )
21722174 {
21732175 throw std::runtime_error (" Cannot call this function from within a callback. "
21742176 " This operation is only available on the main model." );
21752177 }
2176- if (mode == XPRESS_MODEL_MODE::CALLBACK && m_mode == XPRESS_MODEL_MODE::MAIN)
2178+ if (mode == XPRESS_MODEL_MODE::CALLBACK_ && m_mode == XPRESS_MODEL_MODE::MAIN)
21772179 {
21782180 throw std::runtime_error (" This function can only be called from within a callback. "
21792181 " It is not available on the main model." );
@@ -2182,14 +2184,14 @@ void Model::_check_expected_mode(XPRESS_MODEL_MODE mode)
21822184
21832185xpress_cbs_data Model::cb_get_arguments ()
21842186{
2185- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2187+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
21862188 return cb_args;
21872189}
21882190
21892191// NOTE: XPRSgetcallbacksolution return a context dependent solution
21902192double Model::_cb_get_context_solution (VariableIndex variable)
21912193{
2192- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2194+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
21932195 // Xpress already caches solutions internally
21942196 int p_available = 0 ;
21952197 int colidx = _checked_variable_index (variable);
@@ -2207,7 +2209,7 @@ double Model::_cb_get_context_solution(VariableIndex variable)
22072209// otherwise falls back to the current incumbent solution.
22082210double Model::cb_get_solution (VariableIndex variable)
22092211{
2210- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2212+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
22112213 if (cb_where == CB_CONTEXT::intsol || cb_where == CB_CONTEXT::preintsol)
22122214 {
22132215 // Context provides a candidate integer solution - return it directly
@@ -2223,7 +2225,7 @@ double Model::cb_get_solution(VariableIndex variable)
22232225// chgbranchobject, nodelpsolved, optnode). It throws in other contexts.
22242226double Model::cb_get_relaxation (VariableIndex variable)
22252227{
2226- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2228+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
22272229 if (cb_where != CB_CONTEXT::bariteration && cb_where != CB_CONTEXT::cutround &&
22282230 cb_where != CB_CONTEXT::chgbranchobject && cb_where != CB_CONTEXT::nodelpsolved &&
22292231 cb_where != CB_CONTEXT::optnode)
@@ -2240,13 +2242,13 @@ double Model::cb_get_incumbent(VariableIndex variable)
22402242
22412243void Model::cb_set_solution (VariableIndex variable, double value)
22422244{
2243- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2245+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
22442246 cb_sol_cache.emplace_back (_checked_variable_index (variable), value);
22452247}
22462248
22472249void Model::cb_submit_solution ()
22482250{
2249- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2251+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
22502252
22512253 auto &sol = cb_sol_cache;
22522254 if (sol.empty ())
@@ -2276,7 +2278,7 @@ void Model::cb_submit_solution()
22762278
22772279void Model::cb_exit ()
22782280{
2279- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2281+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
22802282 _check (XPRSinterrupt (m_model.get (), POI_XPRS_STOP_USER));
22812283}
22822284
@@ -2326,7 +2328,7 @@ void Model::_cb_add_cut(const ScalarAffineFunction &function, ConstraintSense se
23262328void Model::cb_add_lazy_constraint (const ScalarAffineFunction &function, ConstraintSense sense,
23272329 CoeffT rhs)
23282330{
2329- _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2331+ _check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
23302332 if (cb_where != CB_CONTEXT::nodelpsolved && cb_where != CB_CONTEXT::optnode &&
23312333 cb_where != CB_CONTEXT::preintsol && cb_where != CB_CONTEXT::prenode)
23322334 {
@@ -2431,7 +2433,7 @@ struct Model::CbWrap
24312433
24322434 try
24332435 {
2434- model->_check_expected_mode (XPRESS_MODEL_MODE::CALLBACK );
2436+ model->_check_expected_mode (XPRESS_MODEL_MODE::CALLBACK_ );
24352437 model->cb_sol_cache .clear ();
24362438 model->cb_where = static_cast <CB_CONTEXT>(Where);
24372439 model->cb_args = &cb_args;
0 commit comments