Show / Hide Table of Contents

Class EvaluationController

The Controller class for the evaluation REST interface.

Inheritance
object
ControllerBase
EvaluationController
Inherited Members
ControllerBase.StatusCode(int)
ControllerBase.StatusCode(int, object)
ControllerBase.Content(string)
ControllerBase.Content(string, string)
ControllerBase.Content(string, string, Encoding)
ControllerBase.Content(string, MediaTypeHeaderValue)
ControllerBase.NoContent()
ControllerBase.Ok()
ControllerBase.Ok(object)
ControllerBase.Redirect(string)
ControllerBase.RedirectPermanent(string)
ControllerBase.RedirectPreserveMethod(string)
ControllerBase.RedirectPermanentPreserveMethod(string)
ControllerBase.LocalRedirect(string)
ControllerBase.LocalRedirectPermanent(string)
ControllerBase.LocalRedirectPreserveMethod(string)
ControllerBase.LocalRedirectPermanentPreserveMethod(string)
ControllerBase.RedirectToAction()
ControllerBase.RedirectToAction(string)
ControllerBase.RedirectToAction(string, object)
ControllerBase.RedirectToAction(string, string)
ControllerBase.RedirectToAction(string, string, object)
ControllerBase.RedirectToAction(string, string, string)
ControllerBase.RedirectToAction(string, string, object, string)
ControllerBase.RedirectToActionPreserveMethod(string, string, object, string)
ControllerBase.RedirectToActionPermanent(string)
ControllerBase.RedirectToActionPermanent(string, object)
ControllerBase.RedirectToActionPermanent(string, string)
ControllerBase.RedirectToActionPermanent(string, string, string)
ControllerBase.RedirectToActionPermanent(string, string, object)
ControllerBase.RedirectToActionPermanent(string, string, object, string)
ControllerBase.RedirectToActionPermanentPreserveMethod(string, string, object, string)
ControllerBase.RedirectToRoute(string)
ControllerBase.RedirectToRoute(object)
ControllerBase.RedirectToRoute(string, object)
ControllerBase.RedirectToRoute(string, string)
ControllerBase.RedirectToRoute(string, object, string)
ControllerBase.RedirectToRoutePreserveMethod(string, object, string)
ControllerBase.RedirectToRoutePermanent(string)
ControllerBase.RedirectToRoutePermanent(object)
ControllerBase.RedirectToRoutePermanent(string, object)
ControllerBase.RedirectToRoutePermanent(string, string)
ControllerBase.RedirectToRoutePermanent(string, object, string)
ControllerBase.RedirectToRoutePermanentPreserveMethod(string, object, string)
ControllerBase.RedirectToPage(string)
ControllerBase.RedirectToPage(string, object)
ControllerBase.RedirectToPage(string, string)
ControllerBase.RedirectToPage(string, string, object)
ControllerBase.RedirectToPage(string, string, string)
ControllerBase.RedirectToPage(string, string, object, string)
ControllerBase.RedirectToPagePermanent(string)
ControllerBase.RedirectToPagePermanent(string, object)
ControllerBase.RedirectToPagePermanent(string, string)
ControllerBase.RedirectToPagePermanent(string, string, string)
ControllerBase.RedirectToPagePermanent(string, string, object, string)
ControllerBase.RedirectToPagePreserveMethod(string, string, object, string)
ControllerBase.RedirectToPagePermanentPreserveMethod(string, string, object, string)
ControllerBase.File(byte[], string)
ControllerBase.File(byte[], string, bool)
ControllerBase.File(byte[], string, string)
ControllerBase.File(byte[], string, string, bool)
ControllerBase.File(byte[], string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(byte[], string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.File(byte[], string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(byte[], string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.File(Stream, string)
ControllerBase.File(Stream, string, bool)
ControllerBase.File(Stream, string, string)
ControllerBase.File(Stream, string, string, bool)
ControllerBase.File(Stream, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(Stream, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.File(Stream, string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(Stream, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.File(string, string)
ControllerBase.File(string, string, bool)
ControllerBase.File(string, string, string)
ControllerBase.File(string, string, string, bool)
ControllerBase.File(string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.File(string, string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.File(string, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.PhysicalFile(string, string)
ControllerBase.PhysicalFile(string, string, bool)
ControllerBase.PhysicalFile(string, string, string)
ControllerBase.PhysicalFile(string, string, string, bool)
ControllerBase.PhysicalFile(string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.PhysicalFile(string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.PhysicalFile(string, string, string, DateTimeOffset?, EntityTagHeaderValue)
ControllerBase.PhysicalFile(string, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
ControllerBase.Unauthorized()
ControllerBase.Unauthorized(object)
ControllerBase.NotFound()
ControllerBase.NotFound(object)
ControllerBase.BadRequest()
ControllerBase.BadRequest(object)
ControllerBase.BadRequest(ModelStateDictionary)
ControllerBase.UnprocessableEntity()
ControllerBase.UnprocessableEntity(object)
ControllerBase.UnprocessableEntity(ModelStateDictionary)
ControllerBase.Conflict()
ControllerBase.Conflict(object)
ControllerBase.Conflict(ModelStateDictionary)
ControllerBase.Problem(string, string, int?, string, string)
ControllerBase.ValidationProblem(ValidationProblemDetails)
ControllerBase.ValidationProblem(ModelStateDictionary)
ControllerBase.ValidationProblem()
ControllerBase.ValidationProblem(string, string, int?, string, string, ModelStateDictionary)
ControllerBase.Created()
ControllerBase.Created(string, object)
ControllerBase.Created(Uri, object)
ControllerBase.CreatedAtAction(string, object)
ControllerBase.CreatedAtAction(string, object, object)
ControllerBase.CreatedAtAction(string, string, object, object)
ControllerBase.CreatedAtRoute(string, object)
ControllerBase.CreatedAtRoute(object, object)
ControllerBase.CreatedAtRoute(string, object, object)
ControllerBase.Accepted()
ControllerBase.Accepted(object)
ControllerBase.Accepted(Uri)
ControllerBase.Accepted(string)
ControllerBase.Accepted(string, object)
ControllerBase.Accepted(Uri, object)
ControllerBase.AcceptedAtAction(string)
ControllerBase.AcceptedAtAction(string, string)
ControllerBase.AcceptedAtAction(string, object)
ControllerBase.AcceptedAtAction(string, string, object)
ControllerBase.AcceptedAtAction(string, object, object)
ControllerBase.AcceptedAtAction(string, string, object, object)
ControllerBase.AcceptedAtRoute(object)
ControllerBase.AcceptedAtRoute(string)
ControllerBase.AcceptedAtRoute(string, object)
ControllerBase.AcceptedAtRoute(object, object)
ControllerBase.AcceptedAtRoute(string, object, object)
ControllerBase.Challenge()
ControllerBase.Challenge(params string[])
ControllerBase.Challenge(AuthenticationProperties)
ControllerBase.Challenge(AuthenticationProperties, params string[])
ControllerBase.Forbid()
ControllerBase.Forbid(params string[])
ControllerBase.Forbid(AuthenticationProperties)
ControllerBase.Forbid(AuthenticationProperties, params string[])
ControllerBase.SignIn(ClaimsPrincipal)
ControllerBase.SignIn(ClaimsPrincipal, string)
ControllerBase.SignIn(ClaimsPrincipal, AuthenticationProperties)
ControllerBase.SignIn(ClaimsPrincipal, AuthenticationProperties, string)
ControllerBase.SignOut()
ControllerBase.SignOut(AuthenticationProperties)
ControllerBase.SignOut(params string[])
ControllerBase.SignOut(AuthenticationProperties, params string[])
ControllerBase.TryUpdateModelAsync<TModel>(TModel)
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string)
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider)
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, params Expression<Func<TModel, object>>[])
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, Func<ModelMetadata, bool>)
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider, params Expression<Func<TModel, object>>[])
ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider, Func<ModelMetadata, bool>)
ControllerBase.TryUpdateModelAsync(object, Type, string)
ControllerBase.TryUpdateModelAsync(object, Type, string, IValueProvider, Func<ModelMetadata, bool>)
ControllerBase.TryValidateModel(object)
ControllerBase.TryValidateModel(object, string)
ControllerBase.HttpContext
ControllerBase.Request
ControllerBase.Response
ControllerBase.RouteData
ControllerBase.ModelState
ControllerBase.ControllerContext
ControllerBase.MetadataProvider
ControllerBase.ModelBinderFactory
ControllerBase.Url
ControllerBase.ObjectValidator
ControllerBase.ProblemDetailsFactory
ControllerBase.User
ControllerBase.Empty
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Quantellia.WMServer.Execution
Assembly: WMServer.dll
Syntax
[Authorize]
[ApiController]
public class EvaluationController : ControllerBase

Constructors

EvaluationController(WMAppDbContext)

Create a new instance and inject an WMAppDbContext

Declaration
public EvaluationController(WMAppDbContext context)
Parameters
Type Name Description
WMAppDbContext context

Methods

Delete(int)

Delete the Evaluation record with the specified Id.

Declaration
[HttpDelete("evaluation/{id}")]
public void Delete(int id)
Parameters
Type Name Description
int id

ID of the Evaluation record to delete.

Evaluate(string, EvaluationArgs)

Executes or initializes a decision model.

Declaration
[HttpPost("evaluate/{id}")]
public Task<ActionResult<EvaluationResult>> Evaluate(string id, EvaluationArgs args)
Parameters
Type Name Description
string id

ID of the decision model to execute.

EvaluationArgs args
Returns
Type Description
Task<ActionResult<EvaluationResult>>

The results calculated by the decision model.

Remarks

The World Modeler execution processor is accessed via the REST API by requesting the evaluate operation. The call syntax for this is:

[application root]/evaluate/{id}

where:

[application root]is the root URL of the application, that is, the full URL to which / is resolved.
{id}is the ID of the DecisionModel that is to be evaluated.
The body of the request must contain a JSON object, formatted as shown below.
{
    "processorID":      string, empty string, or null,
    "returnElements":   [ array of strings  ] or null,
    "arguments":        { empty object or object with name = value pairs } or null,
    "saveAs"
    "UserData":         string or null
}
processorIDThe ID of a processor which has been created by a previous call to Runand is still valid. If this is the first time Run is being called, processorID should be null, or an empty string and the new processor ID will be returned in the response if the call succeeded. See Lifecycle of a processor, below..
returnElementIDsAn array of strings, each of which is the ID, FullyQualifiedName, or Name of a DecisionModelElement in the DecisionModel specified in the id URL arguments. Note that the search for matching elements is performed in the order specified above.

The purpose of this is to allow the caller to limit the data that is returned when the processor evaluates the model to only those elements that the caller is interested in. This improves efficiency and reduces network traffic when large models are evaluated.

The following values may be specified:

nullAll elements in the model and their values are returned
[] (empty array)No elements in the model are returned
["element1","element2"...]The elements whose IDs, FullyQualifiedNames, or Names are included in the array.
argumentsA JSON object containing name = value pairs, where each name identifies an element in the DecisionModel and instructs the processor to set the specified element to the specified value before evaluating the model. Each model element name may be specified either by its FullyQualifiedName or its Name. The value must satisfy the following:
  • Must be a literal constant, or an expression that includes only literal constants or calls to built-in function
  • Must be one of the supported types. In the current version, these are given by the following JSON value types:
    • Numbers (integers and floating point)
    • DateTimes represented as strings.
    • Strings

For example:
Correct

{   "processorID":      null,
                "returnElements":   null,
                "arguments:  {
                                 "stringElement":   "This is a string",
                                 "numberElement":   3.14159,
                                 "dateTimeElement": "10/31/2021"
                             },
                "UserData":    null
            }
Incorrect
{   "processorID":      null,
                "returnElements":   null,
                "arguments:  {
                                 "stringElement":   "This is a string that depends on a " + modelElement,
                                 "numberElement":   3.14159 * aNumericalModelElement,
                                 "dateTimeElement": aDateTimeValuedModelElement 
                             },
                "UserData":    null
            }
saveAsIf the inputs and results of the execution are to be saved, then this arguments specifies the name used to refer to the saved execution. If this arguments is null, then the execution will not be saved.
summaryMay be null.
If the saveAs arguments is not null, then this arguments allows a short summary string to be included in the record of the saved execution run. If saveAs is null, then this arguments is ignored.
documentationMay be null.
If the saveAs arguments is not null, then this arguments allows a longer documentation string to be included in the record of the saved execution run.The MIME type of the string must be specified in the documentationMIMEType arguments.
If saveAs is null, then this arguments is ignored.
documentationMIMETypeIf both the saveAs arguments and the documentation arguments are not null, then this arguments must be set to the string identifying the MIME type of text in the documentation arguments.
If either saveAs or documentation are null, then this arguments is ignored.
UserDataAn optional, user-defined text string that can be passed with the call. If defined, thie string will be returned in the response to this call. This can be used for associating response instances with the calls they belong to, for example, to sort the sequence of returned responses to be the same as the order in which the requests were made.

Lifecycle of a processor

When the World Modeler API receives a request to evaluate a DecisionModel for the first time, it creates a Processor instance that is then associated with the Decision Model for its entire lifetime. As with all other objects in World Modeler, a Processor is identified by its ID, a GUID that will not change for the life of the Processor instance. The mapping between the Processor and its Decision model is immutable; a single processor will always evaluate one and only one Decision Models (although multiple processors may be running evaluations of the same Decision Models in some circumstances). So the relationship between Decision Moldels and Processors in one-to-many.

The lifecyle of a Processor from creation to evaluating its decision model is shown below.

Before a Processor can be used, it must first be initialized. This is a relatively resource-intensive process as the Deicsion Model must be laoded (possibly from the database), source code generated from the model, the source code compiled to binary code, the Processor instance created, the binary code loaded into the Processor, and the Processor initialized. Ideally, this should only be done once, and once initialized, the Processor should be retained and service future requests to evaluate the decision model again with changes to the arguments. For this reason, when a new Processor is created, World Modeler Server stores it in a cache and retrieves it for futuer evaluation requests, using its ID as the cache key.

How the Procssor lifecycle affects API requests

The API Run operation is the primary means of invoking a processor. The interaction with the Processor lifecycle is primarkly via the processorID arguments and the value to which it is set. The normal protocol is as follows.

First time Run is called for a Decision Model:The processorID arguments is set to null. This triggers the initialization process shown in the above diagram, which is necessary to create and configure the Processor the first time it is used, but only the first time.

When the first call to Run for a Decision Model returns, it returns the processorID that was assigned to the new processor, which makes it retrievable from the cache. It is important the clients of the API retain the processorID value so that the cached Processor can be used in future calls to Run.

Subsequent calls to Run for the same Decision ModelIn subsequent calls to Run, the processorID should be set in the requerst body, as shown above. This will prevent re-initialization of a new Processor, will retrieve the existing Processor from the cache, and evaluate the Decision Model with the specified arguments.


  • Note that at any stage, calling Run with processorID = null will invalidate the current Processor and cause a new Processor instance to be created and initialized, following the process shown in the above diagram.
  • Note that re-initializing the Processor will restore the model to its default state and previously calculated values will be reset.

Will a cached Processor always be available in the future?

No. There are two reasons an existing cached processor may "disappear".:
  1. The cache timeout expires. This set set in the instance configuration of the World Modeler Server but is typically set to several hours or longer.
  2. The Decision Model associated with the cached Processor is changed. In this situation, the model must be re-loaded, re-compiled, and the Processor re-initialized.

Handling status code 410 (Gone)

If the ID of a Processor that was once available in the cache, but is no longer available, is used in a call to Run, the status code 410 (Gone) is returned. The reason the Processor has been removed from the cache is also returned in the message field of the response. If a 410 status code is returned as the response to a Run request, a new request should be sent to the Run API with processID = null and the normal procedure followed after that.

Get(string)

Get the full details of the EvaluationEvaluation record with the specified ID.

Declaration
[HttpGet("evaluation/{id}")]
public string Get(string id)
Parameters
Type Name Description
string id

ID of the Evaluation record

Returns
Type Description
string

The full details of the Evaluation record with the requested ID.

GetAll(string)

Get the collection of all Evaluations associated with the specified DecisionModelDecisionModel.

Declaration
[HttpGet("evaluation/all/{decisionModelID}")]
public IEnumerable<string> GetAll(string decisionModelID)
Parameters
Type Name Description
string decisionModelID

ID of the DecisionModel whose Evaluation records are to be retrieved.

Returns
Type Description
IEnumerable<string>

Collection of Evaluation records in short EvaluationDTO form

Put(int, string)

Update the Evaluation record with the specified ID.

Declaration
[HttpPut("evaluation/{id}")]
public void Put(int id, string value)
Parameters
Type Name Description
int id

ID of the Evaluation record to update.

string value

Evaluation object containing the values to update.

In this article
Back to top Copyright © 2025 Quantellia LLC.    Version 2.0.0 Revision 399     Last Updated 1/15/2025    DRAFT DOCUMENTATION. SUBJECT TO CHANGE