Using vissimRequest() in a custom implicit solver

The vissimRequest() function is a general-purpose function for making requests to Embed. A user-written solver uses vissimRequest() to read and write optimization information in a diagram. The general format of vissimRequest() is:

long FAR vissimRequest(long req, long arg2, long arg3)

The first argument (long req) is a message code describing the action for Embed to take. The list of message codes is defined in VSUSER.H, which is installed in Embed-install-directory\VSOLVER. The message codes that pertain to writing a local static solver are listed in the table below.

Message code

Description

VR_EXECUTE

Executes the diagram on iteration without moving time.

VR_GET_BLOCK_PARAMS

Returns a pointer to a block’s parameters.

VR_GET_CONSTRAINTS

Arg2 returns a vector of local constraint values. Ordering of the elements vector can be determined by the value of the ID parameter for the constraint block. Embed sorts in sequential order, from low to high.

VR_GET_SOLVER_INFO

Arg2 returns information related to the diagram and the implicit solver dialog settings in the following manner:

arg2[ 0 ] = number of constraints

arg2[ 1 ] = number of unknowns

arg2[ 2 ] = relaxation value

arg2[ 3 ] = maximum iteration value

arg2[ 4 ] = error tolerance value

VR_GET_UNKNOWNS

Arg2 returns a vector of current local unknown output values. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. Embed sorts in sequential order, from low to high.

VR_GET_UNKNOWNS_INPUT

Arg2 returns a vector of current inputs to the unknown blocks. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. Embed sorts in sequential order, from low to high. (This is useful for the initial condition setting.)

VR_GET_VERSION

Returns the current version of Embed.

VR_GET_VISSIM_STATE

Gets information related to the global state of Embed. The information provided is a copy of the current internal state; modifying it will not change Embed’s state. Arg2 should contain a pointer to a SIM_INFO structure, defined in VSUSER.H, which will be filled in by the vissimRequest() function. Arg3 should contain the size of this structure (sizeof(SIM_INFO)) to allow for version compatibility checking.

VR_SET_UNKNOWNS

Sets diagram unknowns based on the vector passed as arg2. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. Embed sorts in sequential order, from low to high.