// h02bb Example Program Text // C# version, NAG Copyright 2012 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class H02BBE { // Specify data file as a command line argument. // It defaults to the named file specified below otherwise. static string datafile = "ExampleData/h02bbe.d"; const int liwork = 1000; const int lrwork = 1000; static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { DataReader sr = new DataReader(datafile); double bigbnd = 0.0, objmip = 0.0, tolfes = 0.0, toliv = 0.0; int i = 0, intfst = 0, itmax = 0, j = 0, m = 0, maxdpt = 0, maxnod = 0, msglvl = 0, n = 0; double[] rwork = new double[1000]; int[] iwork = new int[1000]; Console.WriteLine("h02bb Example Program Results"); // Skip heading in data file sr.Reset(); sr.Reset(); n = int.Parse(sr.Next()); m = int.Parse(sr.Next()); double[,] a = new double[m, n]; double[] x = new double[n]; double[] bl = new double[n + m]; double[] bu = new double[n + m]; double[] cvec = new double[n]; int[] intvar = new int[n]; // // Read ITMAX, MSGLVL, MAXNOD, INTFST, MAXDPT, TOLFES, TOLIV, // CVEC, A, BIGBND, BL, BU, INTVAR and X from data file // sr.Reset(); itmax = int.Parse(sr.Next()); msglvl = int.Parse(sr.Next()); sr.Reset(); maxnod = int.Parse(sr.Next()); sr.Reset(); intfst = int.Parse(sr.Next()); maxdpt = int.Parse(sr.Next()); sr.Reset(); tolfes = double.Parse(sr.Next(), CultureInfo.InvariantCulture); toliv = double.Parse(sr.Next(), CultureInfo.InvariantCulture); sr.Reset(); for (i = 1; i <= n; i++) { cvec[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { a[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } } sr.Reset(); bigbnd = double.Parse(sr.Next(), CultureInfo.InvariantCulture); sr.Reset(); for (i = 1; i <= n + m; i++) { bl[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1; i <= n + m; i++) { bu[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } sr.Reset(); for (i = 1; i <= n; i++) { intvar[i - 1] = int.Parse(sr.Next()); } sr.Reset(); for (i = 1; i <= n; i++) { x[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // // Solve the IP problem // int ifail; H.h02bbOptions options = new H.h02bbOptions(); H.h02bb(ref itmax, msglvl, n, m, a, bl, bu, intvar, cvec, maxnod, intfst, maxdpt, ref toliv, ref tolfes, ref bigbnd, x, out objmip, iwork, rwork, options, out ifail); // } } }