# Model Class

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

Defines a model that has expressions and constraints.

## Inheritance Hierarchy

System.Object

Microsoft.SolverFoundation.Services.Model

**Namespace:** Microsoft.SolverFoundation.Services

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

## Syntax

```
'Declaration
Public NotInheritable Class Model
```

```
public sealed class Model
```

```
public ref class Model sealed
```

```
[<Sealed>]
type Model = class end
```

```
public final class Model
```

The Model type exposes the following members.

## Properties

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

Constraints | Gets a collection of constraints that are defined directly in a model. | |

Decisions | Gets a collection of decisions that are defined directly in a model. | |

Goals | Gets a collection of goals that are defined directly in a model. | |

IsEmpty | Gets a value that indicates whether a model has no decisions, parameters, constraints, or goals. | |

Name | Gets or sets the name of a model. | |

Parameters | Gets all parameters that are defined in a model. | |

RandomParameters | Gets all random parameters that are defined in a model. | |

RecourseDecisions | Gets all recourse decisions that are defined in a model. | |

SubmodelInstances | Gets all instantiations of submodels created directly in a model. | |

Submodels | Gets all submodels created directly in a model. | |

Tuples | Gets all tuples that are defined in a model. |

Top

## Methods

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

Abs | Computes the absolute value of a decision, formula, goal, or constraint. | |

AddConstraint(String, Term) | Adds a constraint to the model.. | |

AddConstraint(String, String) | Adds a constraint to a model by parsing an OML expression. | |

AddConstraints | Adds a group of constraints to a model. | |

AddDecision(Decision) | Adds a decision to a model. | |

AddDecision(RecourseDecision) | Adds a recourse decision to a model (for stochastic programming). | |

AddDecisions(array<Decision[]) | Adds a group of decisions to a model. | |

AddDecisions(array<RecourseDecision[]) | Adds a group of recourse decisions to a model (for stochastic programming). | |

AddGoal(String, GoalKind, Term) | Adds a goal to a model. | |

AddGoal(String, GoalKind, String) | Adds a goal to a model by parsing an OML expression. | |

AddGoals | Adds a group of goals to a model. | |

AddParameter(Parameter) | Adds a parameter to a model. | |

AddParameter(RandomParameter) | Adds a random parameter to a model for stochastic programming. | |

AddParameters(array<Parameter[]) | Adds a group of parameters to a model. | |

AddParameters(array<RandomParameter[]) | Adds a group of random parameters to a model for stochastic programming. | |

AddTuple | Adds a tuple to a model. | |

AddTuples | Adds a group of tuples to a model. | |

AllDifferent | Ensures that all terms in a model are different. | |

And | Performs a Boolean AND operation. | |

ArcCos | Computes the arccosine of a term. | |

ArcSin | Computes the arcsine of a term. | |

ArcTan | Computes the arctangent of a term. | |

AtMostMofN | Tests whether a maximum of m inputs are true. | |

Ceiling | Computes the smallest integer that is greater than or equal to the argument. | |

Cos | Computes the cosine of a term. | |

Cosh | Computers the hyperbolic cosine | |

CreateInstance | Creates an instance of a model. | |

CreateSubModel | Creates a submodel within the current model. | |

Difference | Subtracts one term from another term. | |

Equal(array<Term[]) | Tests all inputs for equality. | |

Equal(array<Term[], Tuples) | Tests a tuple for membership in an array of tuples. | |

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

ExactlyMofN | Tests whether exactly a specified number of inputs are true. | |

Exp | Computes e raised to the power specified by the input. | |

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

Floor | Computes the largest integer that is less than or equal to the argument. | |

ForEach | Creates a term for each element. | |

ForEachWhere | Creates a term for each element if a condition is met. | |

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

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

Greater | Tests whether all inputs occur in decreasing order. | |

GreaterEqual | Tests whether all inputs are decreasing or equal in value. | |

If | Returns the second or third argument, depending on whether the condition is true. | |

Implies | Tests for logical implication between two inputs. | |

Less | Tests whether all inputs occur in increasing order. | |

LessEqual | Tests whether all inputs are increasing or equal in value. | |

Log | Computes the natural logarithm of the term. | |

Log10 | Computes the base 10 logarithm of the term. | |

Max | Returns the largest argument. | |

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

Min | Returns the smallest argument. | |

Negate | Computes the arithmetic negation of a term. | |

Not | Computes the logical negation of a term. | |

Or | Performs a logical OR operation on a term. | |

Power | Raises a term to the power of a specified value. | |

Product | Multiplies all the inputs. | |

Quotient | Divides one term by another. | |

RemoveConstraint | Removes a constraint from a model. | |

RemoveDecision(Decision) | Removes an unused decision from a model. | |

RemoveDecision(RecourseDecision) | Removes an unused recourse decision from a model. | |

RemoveGoal | Removes a goal from a model. | |

RemoveGoals | Removes goals from a model. | |

RemoveParameter(Parameter) | Removes an unused parameter from a model. | |

RemoveParameter(RandomParameter) | Removes an unused random parameter from a model. | |

RemoveSubModel | Removes a submodel from a model. | |

Sin | Computes the sine for a term. | |

Sinh | Computes the hyperbolic sine for a term. | |

Sos1 | Creates a constraint for a special ordered type 1 set. | |

Sos2 | Creates a constraint for a special ordered set reference row. | |

Sqrt | Computes the square root for a term. | |

Sum(array<Term[]) | Computes the sum of the inputs. | |

Sum(Term, Term) | Computes the sum of the inputs. | |

Tan | Computes the tangent for a term. | |

Tanh | Computes the hyperbolic tangent for a term. | |

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

Top

## Remarks

The Model class can be used to construct and modify models. You can add arithmetic and logical expressions to models. In addition, you can add constraints expressed over domains of Boolean, integer, and real variables.

The items that make up a Model object are Goals, Constraints, Parameters, and Decisions properties.

You can load, save, and solve models by using the SolverContext class.

## 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.