Error Messages/40573

< Error Messages
Revision as of 22:51, 10 March 2016 by Bbecane (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Message examples

The objective to NlpDefine evaluates to an array indexed by 'My_j'.  
The objective must evaluate to a scalar in each individual optimization problem (when 'X' is indexed only by 'Vars').

Cause

When solving a non-linear optimization defined with NlpDefine, the search process plugs in a value into the decision variable «x» and evaluates the objective. The decision variable is the parameter passed to NlpDefine in the «x» parameter and will be indexed by the index passed in the «Vars» parameter. The objective is then evaluated, and it is expected that the objective will be a single value. This error results when the computed value for the objective is an array.

With an array objective, it is ambiguous as to which quantity you are optimizing. A change to the decision variable might increase the first element of the objective and simultaneously decrease the second element of the objective. If that were to happen, where should it search next? Because of this ambiguity, an error is issued when the objective is array-valued.

Remedies

Fixing this problem depends on what your intention is.

First, the error may simply uncover an error in your logic. Maybe you forgot to apply an array-reducing function such as Sum, Max, or Subscript that you had intended to apply. In this case, simply fix your model, the dimension will be removed, and the problem will be resolved.

It may be that the array-valued objective was intentional, and that you had intended to solve multiple distinct optimization problems, hence you had multiple objectives. The same situation might occur if your optimization solves in Mid-mode evaluation, but gets this error in an uncertainty mode, because it does not array-abstract over the Run index.

There are two parameters to NlpDefine that can be used to instruct NlpDefine to array abstract in a situation like this. These parameters are the «Over» and «SetContext» parameters. The «Over» parameter is quite easy to use -- you just list the indexes that you want to abstract over, or you can list an array that contains the indexes you want to abstract over, and NlpDefine will create a separate optimization problem for each combination of index values. One trick is to simply place the objective in the «Over» parameter, which works as long as the definition of your decision variable is set to a 1-D array indexed by «Vars».

Use of «Over» by itself allows NlpDefine to array abstract correctly without encountering this error, but it may do so very inefficiently. At each step in the search process, your model will still be computing an array-valued objective, and the optimizer simply knows to use only the element of that result associated with the current problem instance. Hence, a lot of wasted computation gets performed.

To improve the efficiency of the computation when array abstracting during an optimization, the «SetContext» parameter can be utilized to restrict the evaluation to single elements at key points in your model. These key points are referred to as the context variables, and by using these appropriately, you can focus the computation onto a single slice of interest, so slices that won't be used for a particular optimization are not computed. See NlpDefine, or the Analytica Optimizer Guide, for more details on using «SetContext».

See Also

Comments


You are not allowed to post comments.