/********************************************************
Mosel User Guide Example Problems
=================================
file ugarray.cs
```````````````
Accessing modeling objects (sparse arrays).
(c) 2013 Fair Isaac Corporation
author: S.Heipcke, Apr. 2013
********************************************************/
using System;
using System.IO;
using Mosel;
namespace ugarray.cs {
public class ugarray {
///
/// Main entry point for the application
///
[STAThread]
static void Main(string[] args) {
XPRMArray varr;
XPRMSet[] sets;
XPRMValue[] vindex;
int dim;
// Initialize Mosel
XPRM mosel = XPRM.Init();
// Compile and load a model
XPRMModel model = mosel.CompileAndLoad("transport.mos");
// Run the model
model.Run();
// Get model object 'flow', it must be an array
varr=(XPRMArray)model.FindIdentifier("flow");
dim = varr.Dim; // Get the number of dimensions of the array
sets = varr.IndexSets; // Get the indexing sets
// Enumerate over the true entries
foreach(int[] indices in varr.TEIndices)
{
// Get the values for this index
vindex = varr.DereferenceIndex(indices);
Console.Write("flow(");
for(int i=0;i