Error Messages/20249

Error message text

 The 'Variable Side_material' is not valid as a «SetContext» variable in DefineOptimization because
 'Side_material_cost' is defined as a Table that has 'Side_material' as one of its table indexes.
 If 'Side_material' were to be set to a scalar, as the optimizer would do when using it as a «SetContext»
 variable, it would break the Table in 'Side_material_cost'.


This error occurs when you've used the «SetContext» parameter of DefineOptimization or NlpDefine, and passed that parameter the identifier of a variable that cannot be used in «SetContext». In particular, the variable cannot be used in «SetContext» because a Table depends on it. Using it as a «SetContext» variable would break the table.

You use «SetContext» for efficiency reasons when solving array-abstracted non-linear optimization problems. If you don't use «SetContext», Analytica may compute array results for many of the intermediate variables in your model that include cells that aren't relevant to the current optimization. Instead of computing all those extra cells and then throwing most of the work away, judicious use of «SetContext» can slice the computation down to the relevant slices early in the computation, reducing dimensionality during the course of solving any single optimization problem.

To use «SetContext», you have to find (or design) special choke points in your model -- the «SetContext» variables. These variables cannot be indexes operated over by other expressions, or used in table expressions. They need to be downstream of your decision variables, and up-stream from your DefineOptimization or NlpDefine call in order to be relevant. They also cannot be used in the computation of another variable's domain. Any of those uses of the variable would cause other pieces of your model to break if the variable is restricted to a slice during the optimization.


If your only problem is that the variable is used as the index of a table, then you probably just need to use a DetermTable instead of a Table. The DetermTable can adapt to having the variable narrowed to a single value.

To do this, you'll first want to take the «SetContext» variable and make sure its domain is set. It should contain the set of possible values -- this is likely the same thing you have in your definition currently. You can still keep your definition as an index. Then, you can change the child table to a DetermTable. This will remove the current problem for using this variable as a «SetContext» variable.

See Also


You are not allowed to post comments.