/******************************************************** Xpress-BCL C++ Example Problems =============================== file xbcutex.cxx ```````````````` Simplified version of xbexpl1.cxx showing how to define cuts with BCL. (c) 2008-2024 Fair Isaac Corporation author: S.Heipcke, 2005, rev. Mar. 2011 ********************************************************/ #include #include "xprb_cpp.h" #include "xprs.h" using namespace std; using namespace ::dashoptimization; #define NJ 4 /* Number of jobs */ #define NT 10 /* Time limit */ /**** DATA ****/ double DUR[] = {3,4,2,2}; /* Durations of jobs */ XPRBvar start[NJ]; /* Start times of jobs */ XPRBvar delta[NJ][NT]; /* Binaries for start times */ XPRBvar z; /* Maximum completion time (makespan) */ void jobsModel(XPRBprob &p);/* Basic model formulation */ void jobsSolve(XPRBprob &p);/* Solving and solution printing */ /***********************************************************************/ int XPRS_CC usrcme(XPRSprob oprob, void* vd) { XPRBcut ca[2]; int num; int i=0; XPRBprob *bprob; /* In terms of an example, we add a few additional constraints (without any relation to the original problem) at the second node of the MIP search tree. These constraints/cuts are applied at this node and all its child nodes. */ bprob = (XPRBprob*)vd; bprob->beginCB(oprob); XPRSgetintattrib(oprob, XPRS_NODES, &num); if(num == 2) { ca[0] = bprob->newCut(start[1]+2 <= start[0], 2); ca[1] = bprob->newCut(4*start[2] - 5,3*start[3] <= -17, 2); cout << "Adding constraints:" << endl; for(i=0;i<2;i++) ca[i].print(); if(bprob->addCuts(ca,2)) cout << "Problem with adding cuts." << endl; } bprob->endCB(); return 0; /* Call this function once per node */ } /*************************************************************************/ void jobsModel(XPRBprob &p) { XPRBexpr le; int j,t; /****VARIABLES****/ /* Create start time variables */ for(j=0;j