Constraints

Posted on
Picture of user. davide Joined: 03/13/2020
Hi Open Mx Folks

I'm trying to construct a model where I need to implement a constraint across groups. My model is of the form:

Mxgroup1 {
matrix A
matrix B
}
Mxgroup2 {
matrix C
matrix D
}

And I want to employ the constraint A + B = C + D

Any ideas how I can do this?

Replied on Tue, 03/17/2020 - 10:49
Picture of user. AdminRobK Joined: 01/24/2014

OK, suppose you have two groups, represented by two MxModels respectively named "Group1" and "Group2". That is, the strings in the two MxModels' `name` slots are respectively "Group1" and "Group2". In "Group1", you can make an MxMatrix named "A", and another MxMatrix named "B". In "Group2", you can make an MxMatrix named "C", and another MxMatrix named "D".

Both of those MxModels have to go into another container MxModel. Into that container MxModel, you would also place an MxConstraint, the `expression` of which would be `Group1.A + Group1.B == Group2.C + Group2.D`. That is, you can always refer to an MxMatrix by preceding it with the model-name of the MxModel directly containing it, followed by a period.