Navigation  without Java Scripts

About The Web Equation Solver

Introduction

The Web Equation Solver (WES) is a tool, which makes it possible to do numeric calculation in models based on numeric equations. The WES is task independent and depends just on the possibility to represent tasks as set of numeric equations.

The magic facility of the WES is that it gives the possibility to make multidirectional calculations depending on the set of known (preset) and unknown (void) data. The 'data' term means here the sets of variable used in the equations. Using preset data and the set of the numeric equations the WES tries to calculate unknown data and does it if it is possible.

Say if the model represented by the equation

Cost=Price*Amount,

Then we can see that there is tree possible ways to use it

1) Cost=Price*Amount, if Price and Amount are known and Cost is void

2) Price=Cost/Amount, if Cost and Amount are known and the Price is void

3) Amount=Cost/Price, if Cost and Price are known and Amount is void

The WES considers the variable known if it has numeric value (INTEGER or REAL). Opposite this the WES considers the variable unknown if it's value is an empty string. The result of the calculation is REAL.

So if user sends to the WES the set of data as:

Amount = 10,

Cost = 1200,

Price = "",

Then WES will use the way No 2 (Price=Cost/Amount) and the result will be

Amount = 10,

Cost = 1200,

Price=120.

The model described above is a very easy model represented just by one equation. Real model can have a set of numeric equations and conditions.

The Web Solver works via the Internet or the Intranet communication using CGI Protocol.

It is not necvessary to have any other software on the client computer except usual Internet communication tools like MS Internet Explorer, Netscape Navigator etc.

The User Interface and the Calculation Model for the communication with the WES can be programmed by writing the appropriate .HTM files.

Programming of the Web Solver

To program the WES it is needed to prepare two pages in HTML-format:
The Start page for the task, which is used as the initial page.
The Template page, which is used by the WES to send the results of the calculations to the user and to receive new data.

The Template page and the Start page is usually almost the same. The only difference is, that in the Template page you should use some special symbols and some definitions. When the WES solves the equation set it replaces some symbols and sends this modified page to the user. Then user makes new data inputs and the process continues the same way. Thus the data exchange between User and the Web Solver is based on the dynamically created at the each step HTML pages

First we should consider the structure and coding of the Template page, because of it is the main page, which is used in the process of the communication.

The template page must contain some necessary special data:
Equations
The name of the template page
Input fields
Message output field
Resulting data coloring scripts

The equations must be entered to the Template page in the form (we use here the equation explained above):

<INPUT TYPE="HIDDEN" NAME="slvRULE" VALUE="Price*Amount+(-1)*Cost">

Where:

"slvRule" is predefined name

"Price*Amount+(-1)*Cost" is the equation.

You can see that the form of the equation differs from the form discussed before. It is because of the current version of the Web Solver permits using just first order linear equations and can understand just operations plus (+) and multiply (*). If you need the subscription operation, then it should be used as the multiplication by (-1). Also the equations must be in the form where left (or right) part of the equation is 0. Then it is not needed to use this part of the equation.

Thus the equation explained before in the form

Cost=Price*Amount

is the same as

Price*Amount-Cost=0

And Web Solver will understand it in the form

Price*Amount+(-1)*Cost

If the model has more then one equation then equations must be delimited by comma and CR. This can be seen below:

<INPUT TYPE="HIDDEN" NAME="slvRULE"

VALUE="Price*Amount+(-1)*Cost,

Amount1+Amount2+(-1)*Amount ">

It means that Variable Amount can be found as the sum of the "Amount1" and "Amount2"

The name of the template page

The name of the template page tells to the Web Solver what the name of the file used as the template at the next step.

It should be entered in the form:

<INPUT TYPE="HIDDEN" NAME="slvTEMPL" VALUE=" EXAMPLE.TPL">

where

"slvTEMPL" is the predefined name and

"EXAMPLE.TPL" is the name of the HTML page used as the template.

Input fields

The Input fields give the possibility to enter source data to the solver and to get the Solver's solutions.

Each Input field must be used in the form:

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Cost" VALUE="$vCost$">

Where:

The MAXLENGTH may have any convenient value

NAME="Cost" - defines the name of the Variable used also in the equation (we use here names from the described example)

VALUE="$vCost$" points out the place where the output data will be entered by the Web Solver. The Dollar chars are used as the marked brackets and the 'v' char is used to show that the string $vCost$ should be replaced by the value of the Variable "Cost" when it will be found.

Thus for the above example we should have a set of input field definitions:

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Price" VALUE="$vPrice$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Cost" VALUE="$vCost$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount" VALUE="$vAmount$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount1" VALUE="$vAmount1$">

<INPUT TYPE="TEXT" MAXLENGTH="30" NAME="Amount2" VALUE="$vAmount2$">

The Input field can be placed at any needed position in the HTML page say in the table's cell.

Message output field

The purpose of the Message Output field is to send messages from the Web Solver to the End User.

The Web Solver can inform End User about successfully resolved equations or about invalid data and maybe invalid set of data.

The Message Output field must be defined in the form like:

<TEXTAREA ROWS="3" COLS="60" NAME="slvMSG">$mMsg$</TEXTAREA>

Where:

ROWS and COLS may have any reasonable value.

"slvMSG" is the predefined name

$mMsg$ is the predefined string which will be substituted by the Web Solver's message to the End User.

Resolved data marking scripts

During the communication with the End User there can be some situations which Web Solver informs the End User about.

The main message will be sent to the Message Output field. Web Solver also can mark some variables. The way to mark variable is the programmer's choice. Programmer must just place the special data to the template in the form:

$c<VariableName>$ where VariableName is the name of the Variable used in the equation.

Also User may define the script which will replace this special data depending on the event in the form:.

<INPUT TYPE="HIDDEN" NAME="EventName" VALUE="Any String, defined by Programmer">

Where the "EventName" is one of the predefined event names.

There is the set of predefined event names, which can be used:

Wrong Input Data Events:

usrOnInvalidData -If invalid data like string instead of number for the variable entered.

usrOnSrcConflict - If source data and the equations have a conflict.

This needs to be explained a little more detailed.

If we have the equation like

Cost=Price*Amount

and User entered numbers for all variables say like

Cost=100,

Price=15,

Amount=1000,

Then there is the conflict between the source data and the equation - 15*1000 not equals to 100

The Web Solver checks this situation before calculation and informs user if there is the conflict.

Also Web Solver marks conflicted variables using substitution at $c<VariableName>$ for each conflicted Variable.

usrOnResConflict

The same situation as above may happen, when there is no conflict in the source data and equations but there is a conflict between resolved data with the entered data and the equations. The Web Solver checks such a kind of situations after calculation is done. It also can mark variables, which are in the conflict.

Resolution Results:

usrOnPreset - The variable's value was preset by User

usrOnVoid - The variable's Value is void in the User's input

usrOnNotSolved - The variable's Value is void in the User's input and was not resolved

usrOnSolved - The Web Solver resolved the Variable's Value with any result.

usrOnNegative - The Web Solver resolved the Variable's Value. The result is Negative

usrOnZero - The Web Solver resolved the Variable's Value. The result is Zero

Here is an example of the substitution script definitions. We use here just coloring of the results but it can be any other information in the HTML format.

<INPUT TYPE="HIDDEN" NAME="usrOnInvalidData" VALUE="BGCOLOR=#0080ff">

<INPUT TYPE="HIDDEN" NAME="usrOnSrcConflict" VALUE="BGCOLOR=#008000">

<INPUT TYPE="HIDDEN" NAME="usrOnResConflict" VALUE="BGCOLOR=#ffff00">

<INPUT TYPE="HIDDEN" NAME="usrOnPreset" VALUE="">

<INPUT TYPE="HIDDEN" NAME="usrOnVoid" VALUE="">

<INPUT TYPE="HIDDEN" NAME="usrOnSolved" VALUE="BGCOLOR=#00ffff">

<INPUT TYPE="HIDDEN" NAME="usrOnNotSolved" VALUE="BGCOLOR=#00800f">

If it is not needed to mark results then the script can be an empty string. It is also not necessary to use marking rules.