This document is archived and information here might be outdated.  Recommended version.


Set Location Allocation Properties Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Set Location Allocation Properties Snippet

Set Location-Allocation solver parameters, including settings.

[C#]
/// <summary>Set Location-Allocation solver parameters, including settings.</summary>
/// <param name="defaultCutoff"></param>
/// <param name="impedanceTransformationType"></param>
/// <param name="numberofFacilitiesToLocate"></param>
/// <param name="problemType"></param>
/// <param name="targetMarketSharePercentage"></param>
/// <param name="transformationParameter"></param>
/// <returns></returns>
public ESRI.ArcGIS.NetworkAnalyst.INALocationAllocationSolver SetLocationAllocationProperties(System.Object defaultCutoff,
            ESRI.ArcGIS.NetworkAnalyst.esriNAImpedanceTransformationType impedanceTransformationType, System.Int32 numberofFacilitiesToLocate,
            ESRI.ArcGIS.NetworkAnalyst.esriNALocationAllocationProblemType problemType, double targetMarketSharePercentage,
            double transformationParameter)
{
    // The solver settings herein can be configured without binding the solver to a Network Dataset.
    //   However, any base settings or context\layer creation methods require INASolver::Bind(...) to be called.
    ESRI.ArcGIS.NetworkAnalyst.INALocationAllocationSolver naLocationAllocationSolver=new ESRI.ArcGIS.NetworkAnalyst.NALocationAllocationSolverClass();

    // DefaultCutoff is of type Object, in order to allow null to indicate no cutoff
    naLocationAllocationSolver.DefaultCutoff=defaultCutoff;

    // Configure the Location Allocation Problem
    naLocationAllocationSolver.ImpedanceTransformation=impedanceTransformationType;
    naLocationAllocationSolver.NumberFacilitiesToLocate=numberofFacilitiesToLocate;
    naLocationAllocationSolver.ProblemType=problemType;
    naLocationAllocationSolver.TargetMarketSharePercentage=targetMarketSharePercentage;
    naLocationAllocationSolver.TransformationParameter=transformationParameter;

    // Is network travel consider towards or away from the facilities
    naLocationAllocationSolver.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionFromFacility;

    // Output
    naLocationAllocationSolver.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineStraight;

    return naLocationAllocationSolver;
}
[Visual Basic .NET]
''' <summary>Set Location-Allocation solver parameters, including settings.</summary>
''' <param name="defaultCutoff"></param>
''' <param name="impedanceTransformationType"></param>
''' <param name="numberofFacilitiesToLocate"></param>
''' <param name="problemType"></param>
''' <param name="targetMarketSharePercentage"></param>
''' <param name="transformationParameter"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function SetLocationAllocationProperties(ByVal defaultCutoff As System.Object, _
                                                ByVal impedanceTransformationType As ESRI.ArcGIS.NetworkAnalyst.esriNAImpedanceTransformationType, _
                                                ByVal numberofFacilitiesToLocate As System.Int32, _
                                                ByVal problemType As ESRI.ArcGIS.NetworkAnalyst.esriNALocationAllocationProblemType, _
                                                ByVal targetMarketSharePercentage As System.Double, ByVal transformationParameter As System.Double) _
                                                As ESRI.ArcGIS.NetworkAnalyst.INALocationAllocationSolver

    ' The solver settings herein can be configured without binding the solver to a Network Dataset. 
    ' However, any base settings or context\layer creation methods require INASolver::Bind(...) to be called. 
    Dim naLocationAllocationSolver As ESRI.ArcGIS.NetworkAnalyst.INALocationAllocationSolver=New ESRI.ArcGIS.NetworkAnalyst.NALocationAllocationSolverClass()

    ' DefaultCutoff is of type Object, in order to allow null to indicate no cutoff 
    naLocationAllocationSolver.DefaultCutoff=defaultCutoff

    ' Configure the Location Allocation Problem 
    naLocationAllocationSolver.ImpedanceTransformation=impedanceTransformationType
    naLocationAllocationSolver.NumberFacilitiesToLocate=numberofFacilitiesToLocate
    naLocationAllocationSolver.ProblemType=problemType
    naLocationAllocationSolver.TargetMarketSharePercentage=targetMarketSharePercentage
    naLocationAllocationSolver.TransformationParameter=transformationParameter

    ' Is network travel consider towards or away from the facilities 
    naLocationAllocationSolver.TravelDirection=ESRI.ArcGIS.NetworkAnalyst.esriNATravelDirection.esriNATravelDirectionFromFacility

    ' Output 
    naLocationAllocationSolver.OutputLines=ESRI.ArcGIS.NetworkAnalyst.esriNAOutputLineType.esriNAOutputLineStraight

    Return naLocationAllocationSolver

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Geodatabase
  • ESRI.ArcGIS.NetworkAnalyst
  • ESRI.ArcGIS.System