Class UnitConstraints
- java.lang.Object
-
- ptolemy.moml.unit.UnitConstraints
-
- All Implemented Interfaces:
UnitPresentation
public class UnitConstraints extends java.lang.Object implements UnitPresentation
UnitConstraints represents a group, with duplicates allowed, of UnitConstraints. The are two general ways to create an instance of this class. The first requires you to create an instance without any UnitConstraints and then add them with the method addConstraint. The second is to specify a TypedCompositeActor as well as specific nodes and relations in the TypedCompositeActor, and have the UnitConstraintCollection constructor determine which UnitConstraints belong to the collection.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Rowland R Johnson
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description UnitConstraints()
Construct an empty collection of Unit constraints.UnitConstraints(TypedCompositeActor model, java.util.Vector entities, java.util.Vector relations)
Construct a collection of Unit constraints from the specified componentEntities and relations of a model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConstraint(UnitConstraint constraint)
Add a UnitConstraint to the collection.Solution
completeSolution()
Generate a complete solution.java.lang.String
descriptiveForm()
This method generates the descriptive form.java.util.Vector
getConstraints()
Get the constraints in the collection.java.util.Vector
minimalSpanSolutions()
Generate the minimal span solutions of the collection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ptolemy.moml.unit.UnitPresentation
toString
-
-
-
-
Constructor Detail
-
UnitConstraints
public UnitConstraints()
Construct an empty collection of Unit constraints.
-
UnitConstraints
public UnitConstraints(TypedCompositeActor model, java.util.Vector entities, java.util.Vector relations) throws IllegalActionException
Construct a collection of Unit constraints from the specified componentEntities and relations of a model.For each componentEntity each constraints in the form of Unit equation is retrieved and then used a basis to create a Unit constraint to add to the collection. Each port on the componentEntity is inspected to see if it has a Unit specified for it. If so, then that Unit specification is used to create a corresponding Unit constraint that gets added to the collection.
A component entity itself may have Unit constraint(s) that then get added to the collection. For example, the AddSubtract actor would likely have a constraint that requires that the plus, and minus ports be equal.
The relations are then considered. Any relation that connects two ports seen on a component entity in the first step is used to create a Unit equation that gets added to the collection.
- Parameters:
model
- The model containing the component entities.entities
- The component entities.relations
- The relations.- Throws:
IllegalActionException
-
-
Method Detail
-
addConstraint
public void addConstraint(UnitConstraint constraint)
Add a UnitConstraint to the collection.- Parameters:
constraint
- The UnitConstraint to be added to the collection.
-
completeSolution
public Solution completeSolution() throws IllegalActionException
Generate a complete solution.- Returns:
- The solution.
- Throws:
IllegalActionException
-
descriptiveForm
public java.lang.String descriptiveForm()
Description copied from interface:UnitPresentation
This method generates the descriptive form. In addition to the internal form used by the system Units, UnitConstraints, UnitExprs, etc. have a descriptive form that is used by humans. This method generates that form so that humans can easily understand the results generated by the system. For example, an internal representation of a Unit could be 4.1868E7*<2, 1, 1, 0, 0> and its descriptive form would be "calorie".The descriptive form is invariant across Unit Systems. That is, calorie is calorie regardless of the Unit System. But, the internal form may be 4.1868E7*<2, 1, 1, 0, 0> in one Unit System, and 1.0*<2, 1, 1, 0, 0> in another. Therefore the descriptive form is used as the external representation. This makes it possible to save a model under one Unit System, and then load it under a different Unit System.
- Specified by:
descriptiveForm
in interfaceUnitPresentation
- Returns:
- The descriptive form.
- See Also:
UnitPresentation.descriptiveForm()
-
getConstraints
public java.util.Vector getConstraints()
Get the constraints in the collection.- Returns:
- The constraints.
-
minimalSpanSolutions
public java.util.Vector minimalSpanSolutions() throws IllegalActionException
Generate the minimal span solutions of the collection.- Returns:
- The minimal span solutions.
- Throws:
IllegalActionException
-
-