RowVariableModel.AddVariable Method

Solver Foundation 3.0

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Adds a user variable to a model.

Namespace:  Microsoft.SolverFoundation.Services
Assembly:  Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll)

public virtual bool AddVariable(
	Object key,
	out int vid
)

Parameters

key
Type: System.Object
The key for the variable.
vid
Type: System.Int32%
The index of the variable.

Return Value

Type: System.Boolean
true if the user variable is added to the model successfully; false if the model already includes a user variable that is referenced by key or if the model already includes a row that is referenced by key.

Implements

IRowVariableModel.AddVariable(Object, Int32)

The AddVariable method ensures that a user variable that has the specified key is present in the model.

The following table shows the value of vid, depending on key.

key in the model

Value of vid

The model already includes a user variable that is referenced by key.

vid is set to the variable index.

The model already includes a row that is referenced by key.

vid is set to -1.

A new user variable associated with key is added to the model.

vid is set to the new variable index.

Show: