Share via


UnconstrainedNonlinearModel.AddVariable Method

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

The method ensures that a user variable with the given key is in the model.

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

Syntax

'Declaration
Public Overridable Function AddVariable ( _
    key As Object, _
    <OutAttribute> ByRef vid As Integer _
) As Boolean
public virtual bool AddVariable(
    Object key,
    out int vid
)
public:
virtual bool AddVariable(
    Object^ key, 
    [OutAttribute] int% vid
)
abstract AddVariable : 
        key:Object * 
        vid:int byref -> bool 
override AddVariable : 
        key:Object * 
        vid:int byref -> bool 
public function AddVariable(
    key : Object, 
    vid : int
) : boolean

Parameters

Return Value

Type: System.Boolean
True if added successfully, otherwise false.

Implements

IRowVariableModel.AddVariable(Object, Int32%)

Remarks

If the model already includes a user variable referenced by key, the method sets the vid to the variable’s index and returns false. If the model already includes a row referenced by key, the method sets vid to -1 and returns false. Otherwise, the method adds a new user variable associated with key to the model, assigns the next available index to the new variable, sets vid to this index, and returns true. By convention variables get indexes from 1 to VariableCount in the order they were added.

.NET Framework Security

See Also

Reference

UnconstrainedNonlinearModel Class

Microsoft.SolverFoundation.Solvers Namespace