/******************************************************** Xpress-BCL C# Example Problems ============================== file xbgoalobj.cs ````````````````` Archimedian and pre-emptive goal programming using objective functions. (c) 2008 Fair Isaac Corporation authors: S.Heipcke, D.Brett. ********************************************************/ using System; using System.Text; using System.IO; using Optimizer; using BCL; namespace Examples { public class TestAdvGoalObj { const int NGOALS = 3; // **** Data **** string[] Type = {"perc", "abs", "perc"}; string[] Sense = {"max", "min", "max"}; double[] Weight = {100, 1, 0,1}; double[] Deviation = {10, 4, 20}; public void modelgo() { XPRBvar x,y; XPRBctr[] goalCtr = new XPRBctr[NGOALS]; XPRBctr aCtr; double[] Target = new double[NGOALS]; XPRBexpr[] goal = new XPRBexpr[NGOALS]; XPRBexpr wobj; XPRBprob prob; XPRSprob xprsp; int i,g; prob = new XPRBprob("Goal"); // Adding the variables x = prob.newVar("x", BCLconstant.XPRB_PL); y = prob.newVar("y", BCLconstant.XPRB_PL); // Adding a constraint aCtr = prob.newCtr("Limit", 42*x + 13*y <= 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) System.Console.WriteLine(" " + prob.getObjVal()); else System.Console.WriteLine(" " + (goalCtr[g].getAct() - goalCtr[g].getRHS() + Target[g])); } } public static void Main() { XPRB.init(); TestAdvGoalObj TestInstance = new TestAdvGoalObj(); if (XPRB.init() != 0) return; TestInstance.modelgo(); XPRB.finish(); return; } } }