Click or drag to resize

XPRBexprContext Class

An XPRBexprContext allows you to easily dispose of intermediate expression objects created while constructing your model. Once an XPRBexprContext has been created, every expression created by that thread will be linked to the context and will be disposed when the XPRBexprContext is disposed.
Inheritance Hierarchy
SystemObject
  BCLXPRBexprContext

Namespace: BCL
Assembly: xprbdn (in xprbdn.dll) Version: 47.01.01+0ba4e76731516b80760698bbaa939494dae84e49
Syntax
public class XPRBexprContext : IDisposable

The XPRBexprContext type exposes the following members.

Constructors
 NameDescription
Public methodXPRBexprContext Create a new expression context. Any expressions created on this thread from this point onwards will be added to this context, until the context is disposed. If the thread already has an expression context, new expressions will continue to be added to the old context & the new context will not be used.
Top
Methods
 NameDescription
Public methodDispose Free all expressions that are associated with this context.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the XPRBexprContext and optionally releases the managed resources
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize
(Overrides ObjectFinalize)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Remarks
XPRBexpr objects can be created explicitly or by operator overloading, and once created will normally be retained in memory until .NET decides to garbage collect them. As this can waste significant memory, the XPRBexprContext provides a way to easily dispose of your expressions once they are no longer required, without needing to keep a reference to every individual XPRBexpr.
Example
C#
XPRBprob p = new XPRBprob("Chess");
XPRBvar xs = p.newVar("xs");
XPRBvar xl = p.newVar("xl");
using (XPRBexprContext ctx=new XPRBexprContext()) {
  XPRBexpr woodRequired = xs + 3.0*xl;
  p.newCtr("wood", woodRequired<=200.0 );
  XPRBexpr timeRequired = 3.0*cs + 2.0*xl;
  p.newCtr("mc_time", timeRequired<400.0);
}
See Also

Reference

BCL Namespace