# LinearModel Class

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

Represents a linear model with rows and variables.

## Inheritance Hierarchy

System.Object

Microsoft.SolverFoundation.Services.RowVariableModel

Microsoft.SolverFoundation.Services.LinearModel

Microsoft.SolverFoundation.Services.SecondOrderConicModel

Microsoft.SolverFoundation.Solvers.SimplexSolver

**Namespace:** Microsoft.SolverFoundation.Services

**Assembly:** Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll)

## Syntax

```
'Declaration
Public Class LinearModel _
Inherits RowVariableModel _
Implements ILinearModel, ISolverProperties
```

```
public class LinearModel : RowVariableModel,
ILinearModel, ISolverProperties
```

```
public ref class LinearModel : public RowVariableModel,
ILinearModel, ISolverProperties
```

```
type LinearModel =
class
inherit RowVariableModel
interface ILinearModel
interface ISolverProperties
end
```

```
public class LinearModel extends RowVariableModel implements ILinearModel, ISolverProperties
```

The LinearModel type exposes the following members.

## Constructors

Name | Description | |
---|---|---|

LinearModel | Initializes a new instance of the LinearModel class. |

Top

## Properties

Name | Description | |
---|---|---|

CoefficientCount | Gets the number of non-zero coefficients in a linear model. | |

GoalCount | Gets the number of goals in a linear model. | |

Goals | Gets the goal collection of a linear model. | |

Indices | Gets the collection of row and variable indexes for a model. (Inherited from RowVariableModel.) | |

IntegerIndexCount | Gets the number of integer variables in a model. (Inherited from RowVariableModel.) | |

IsMipModel | Gets a value that indicates whether a model is a mixed integer programming (MIP) model. (Inherited from RowVariableModel.) | |

IsQuadraticModel | Gets a value that indicates whether a model has a quadratic term on the objective function. | |

IsSpecialOrderedSet | Gets a value that indicates whether a linear model is a special ordered set. | |

KeyComparer | Gets the object that is used to compare keys for rows or variables. (Inherited from RowVariableModel.) | |

KeyCount | Gets the number of keys that are in a model. (Inherited from RowVariableModel.) | |

Keys | Gets the variable key and row key collection. (Inherited from RowVariableModel.) | |

RowCount | Gets the number of rows in a model. (Inherited from RowVariableModel.) | |

RowIndices | Gets the collection of row indexes of a linear model. (Overrides RowVariableModel.RowIndices.) | |

RowKeys | Gets the collection of row keys. (Inherited from RowVariableModel.) | |

VariableCount | Gets the number of variables in a model. (Inherited from RowVariableModel.) | |

VariableIndices | Gets the collection of variable indexes. (Inherited from RowVariableModel.) | |

VariableKeys | Gets the collection of variable keys. (Inherited from RowVariableModel.) |

Top

## Methods

Name | Description | |
---|---|---|

AddGoal | Creates an ILinearGoal object and adds it to the goal list in a model. | |

AddRow(Object, Int32%) | Adds a row to a linear model. (Overrides RowVariableModel.AddRow(Object, Int32%).) | |

AddRow(Object, SpecialOrderedSetType, Int32%) | Adds a reference row for a special ordered set to a linear model. | |

AddVariable | Adds a user variable to a model. (Inherited from RowVariableModel.) | |

ClearGoals | Clears all the goals in a linear model. | |

Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |

Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |

GetBasic | Returns a value that indicates whether a variable is a basic variable. | |

GetBounds | Returns the bounds for a variable. (Inherited from RowVariableModel.) | |

GetCoefficient(Int32, Int32) | Returns the coefficient of the A matrix in a linear model. | |

GetCoefficient(Int32, Int32, Int32) | Returns the coefficient of the Q matrix on the objective row. | |

GetGoalFromIndex | Returns a goal entry if the row index is associated with a goal. | |

GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |

GetIgnoreBounds | Returns a value that indicates whether the bounds of a variable are ignored. (Inherited from RowVariableModel.) | |

GetIndexFromKey | Returns the index that is associated with a specified key. (Inherited from RowVariableModel.) | |

GetIntegrality | Returns a value that indicates whether a variable is an integer variable. (Inherited from RowVariableModel.) | |

GetKeyFromIndex | Returns the key that is associated with the specified variable index. (Inherited from RowVariableModel.) | |

GetProperty | Returns the value of a property that is at the specified index. (Inherited from RowVariableModel.) | |

GetRowEntries | Returns the collection of non-zero variable entries. | |

GetRowEntryCount | Returns the number of non-zero coefficients for the given row index. | |

GetRowQuadraticEntries | Returns a collection of non-zero variable entries on a quadratic row. | |

GetSpecialOrderedSetTypeRowIndexes | Returns a list of rows for a special ordered set. | |

GetType | Gets the Type of the current instance. (Inherited from Object.) | |

GetValue | Returns the value that is associated with the specified variable index. (Inherited from RowVariableModel.) | |

GetValueState | Returns the value state for a variable. | |

GetVariableEntries | Returns a collection of non-zero column entries. | |

GetVariableEntryCount | Returns the number of non-zero coefficients for a given column variable index. | |

InitModel | Allocates data structures for a new model. | |

IsGoal(Int32) | Returns a value that indicates whether a row identifier is a goal row. | |

IsGoal(Int32, ILinearGoal%) | Returns a value that indicates whether a row identifier is a goal row. | |

IsQuadraticVariable | Returns a value that indicates whether a variable is in any quadratic row. | |

IsRow | Returns a value that indicates whether a variable index corresponds to a row. (Inherited from RowVariableModel.) | |

LoadLinearModel | Loads the information from one linear model into another model. | |

MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |

Preallocate | Allocates data structures for a new linear model. | |

RemoveGoal | Removes a goal row. | |

SetBasic | Sets the basic status for a variable. | |

SetBounds | Sets the bounds for a row. (Inherited from RowVariableModel.) | |

SetCoefficient(Int32, Int32, Rational) | Sets the coefficient of the A matrix in a linear model. | |

SetCoefficient(Int32, Rational, Int32, Int32) | Sets the coefficient of the Q matrix on the objective row. | |

SetIgnoreBounds | Specifies whether the bounds of a variable should be respected or ignored during a solve attempt. (Inherited from RowVariableModel.) | |

SetIntegrality | Specifies whether a variable is an integer variable. (Inherited from RowVariableModel.) | |

SetLowerBound | Sets the lower bound of a variable. (Inherited from RowVariableModel.) | |

SetProperty | Sets a property that is at the specified variable index. (Inherited from RowVariableModel.) | |

SetUpperBound | Sets the upper bound of a variable. (Inherited from RowVariableModel.) | |

SetValue | Sets the value for the specified variable index. (Inherited from RowVariableModel.) | |

ToString | Returns a string that represents the current object. (Inherited from Object.) | |

TryGetIndexFromKey | Attempts to return the variable index that is associated with the specified key. (Inherited from RowVariableModel.) |

Top

## Fields

Name | Description | |
---|---|---|

m_cvidBasic | Represents the number of variables that are marked as basic. | |

m_cvidInt | Represents the number of integer variables. (Inherited from RowVariableModel.) | |

m_mpkeyvid | Represents the mapping from key to variable index. (Inherited from RowVariableModel.) | |

m_qpRowVar | The goal variable that has the QP form. |

Top

## Remarks

Rows and variables for a linear model are identified by a key that can be any object. Rows and variables can be accessed by an index. Indexes are not necessarily contiguous.

## Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.