/******************************************************** Xpress-BCL C# Example Problems ============================== file xbsetops.cs ```````````````` Set operations. (c) 2008 Fair Isaac Corporation authors: S.Heipcke, D.Brett. ********************************************************/ using System; using System.Text; using System.IO; using BCL; namespace Examples { public class TestSetOps { /* Define arrays with index names: note that the restriction to 8 characters does not apply for BCL */ string[] city_names = {"rome", "bristol", "london", "paris", "liverpool"}; string[] port_names = {"plymouth", "bristol", "glasgow", "london", "calais", "liverpool"}; /***********************************************************************/ /**** Create the union of two index sets ****/ public void createUnion(XPRBprob p, XPRBindexSet a, XPRBindexSet b, out XPRBindexSet c, string name) { int i, dummy; c=p.newIndexSet(name,a.getSize()+b.getSize()); for(i=0;i= 0) dummy = c + a.getIndexName(i); } /***********************************************************************/ public static void Main() { XPRB.init(); XPRBindexSet ports,cities,both,places; int i, dummy; XPRBprob p = new XPRBprob("Setops"); /* Initialize BCL */ TestSetOps TestInstance = new TestSetOps(); /* Create sets "cities" and "ports" and add the indices */ cities=p.newIndexSet("cities",5); for (i = 0; i < 5; i++) dummy = cities + TestInstance.city_names[i]; ports=p.newIndexSet("ports",6); for (i = 0; i < 6; i++) dummy = ports + TestInstance.port_names[i]; /* Create the union of "cities" and "ports" and print it */ TestInstance.createUnion(p, cities, ports, out places, "places"); places.print(); /* Create the intersection of "cities" and "ports", print it */ TestInstance.createInter(p, cities, ports, out both, "both sets"); both.print(); return; } } }