/******************************************************** BCL Example Problems ==================== file xbgoalobj.c ```````````````` Archimedian and pre-emptive goal programming using objective functions. (c) 2008-2024 Fair Isaac Corporation author: S.Heipcke, 2005, rev. Mar. 2011 ********************************************************/ #include #include #include #include #include "xprb.h" #include "xprs.h" #define NGOALS 3 /***** Data *****/ const char *Type[] = {"perc", "abs", "perc"}; const char *Sense[] = {"max", "min", "max"}; double Weight[] = {100, 1, 0,1}; double Deviation[] = {10, 4, 20}; double Coeff[NGOALS][3] = {{5, 2, 20}, {-3, 15, 48}, {1.5, 21, 3,8}}; int main(int argc, char **argv) { XPRBvar x[2]; XPRBctr goalCtr[NGOALS], aCtr, wobj; double Target[NGOALS]; XPRBprob prob; int i,g; if(XPRBinit()) return 1; prob = XPRBnewprob("Goal"); /* Adding the variables */ x[0] = XPRBnewvar(prob,XPRB_PL,"x",0,XPRB_INFINITY); x[1] = XPRBnewvar(prob,XPRB_PL,"y",0,XPRB_INFINITY); /* Adding a constraint */ aCtr = XPRBnewctr(prob,"Limit",XPRB_L); XPRBaddterm(aCtr, x[0], 42); XPRBaddterm(aCtr, x[1], 13); XPRBaddterm(aCtr, NULL, 100); /* Goals */ /* goal[0] = 5*x + 2*y - 20; goal[1] = -3*x + 15*y - 48; goal[2] = 1,5*x + 21*y - 3,8; */ for(g=0;g= ":" <= "), Target[g]); if(g==NGOALS-1) printf(" %g\n", XPRBgetobjval(prob)); else printf(" %g\n", (XPRBgetact(goalCtr[g]) - XPRBgetrhs(goalCtr[g])) + Target[g]); } XPRBdelprob(prob); XPRBfinish(); return 0; }