Improvements for symbolic expressions simplification in TMS Analytics & Physics developing library


Wednesday, December 20, 2017

One of the unique features of the Analytics library is symbolic derivatives calculation. The derivative can be calculated just with several lines of Delphi code, for an example:

  f, df: string;
  t: TTranslator;
  t:= TTranslator.Create;
  f:= 'x^2*e^(x/3)';
  df:= t.Derivative(f, 'x');

The Analytics library guarantees that the result derivative expression is syntactically and mathematically correct and satisfies the derivative rules. From the first version, the derivative algorithm automatically simplifies the result derivative expression. Nevertheless, the library is not a Computer Algebra system, so it cannot simplify all the result expressions to the optimal representation.

New version 2.3 introduces new simplification algorithms for providing more readable and short symbolic derivatives. New simplification algorithms include: constants reducing in sum and product expressions; reducing nested sum or product expressions to one; reducing negation pairs in product expressions and others.

There are some examples of functions and their derivative expressions, evaluated with the old version of the library and with the 2.3 version:

f(x)       : x^2*e^(x/3)
df/dx (old): (2*x)*e^(x/3)+(e^(x/3)*(1/3))*x^2
df/dx (2.3): 2*x*e^(x/3)+e^(x/3)/3*x^2

f(x)       : 2*x^3+A/4*x^2-x/3
df/dx (old): (3*x^2)*2+((2*x)*A)/4-1/3
df/dx (2.3): 6*x^2+1/2*x*A-1/3

f(x)       : (A/2)*arctan(x^2)
df/dx (old): ((1/(1+(x^2)^2))*(2*x))*(A/2)
df/dx (2.3): x*A/(1+x^4)

f(x)       : P{n-1 m+2}(x)
df/dx (old): ((((n-1)+1)-(m+2))*P{(n-1)+1 m+2}(x) -(((n-1)+1)*x)*P{n-1 m+2}(x))/(x^2-1)
df/dx (2.3): ((n-m-2)*P{n m+2}(x)-n*x*P{n-1 m+2}(x))/(x^2-1)

As can be seen from the examples, new version gives shorter and more readable symbolic expressions for different function cases. The simplified representation of the formulae also reduces the calculation time. The new library version is already available here

Bruno Fierens


This blog post has not received any comments yet. Add a comment.

Document and test your REST API using OpenAPI/Swagger support in TMS XData


Tuesday, October 10, 2017

TMS XData 2.7 has been just release with lots of new features. The most interesting one, in my opinion, is OpenAPI/Swagger support.

TMS XData server can now optionally provide a JSON file containing the OpenAPI Specification (OAS, formerly Swagger) for your whole server API. This opens up a lot of possibilities, usage of several tools of the OpenAPI ecosystem is now possible. Main one would be the Swagger UI, a web front-end to describe and test your API.

Enabling support for OpenAPI

To enable OpenAPI support in your server, just use the unit XData.OpenAPI.Service and call the method RegisterOpenAPIService anywhere in your application:
uses {...}, XData.OpenAPI.Service;
It's as simple as that. XData will scan your whole API and build the specification file describing that API automatically. The specification will be very detailed as XData has all the metadata for your API: the method parameters, the mappings for entity classes, the data types, etc.

Retrieving the OpenAPI Specification (OAS) file

The OAS file is available through a GET request to the URL "/openapi/swagger.json" relative to your server root URL. For example, if your server root is http://myserver/tms/xdata/, then you will be able to access the file from this URL:

GET http://myserver/tms/xdata/openapi/swagger.json

Using Swagger UI

One of the main use cases is to be able to use the Swagger UI. It's a web-based front-end to dynamically document and test your API. From their website: "Swagger UI allows anyone - be it your development team or your end consumers - to visualize and interact with the API's resources without having any of the implementation logic in place. It's automatically generated from your Swagger specification, with the visual documentation making it easy for back end implementation and client side consumption.".

You can visit their site for more information, but here are quick steps to see it in action from your own server:

1. Create your XData Server and enable OpenAPI support as described above.

2. Enable CORS in your TXDataServerModule:
    Module.AccessControlAllowOrigin := '*';
3. Open the existing live demo of the Swagger UI at

4. In the edit box that appears at the top of the page, just type the URL that returns the OpenAPI Specification. For example, "http://myserver/tms/xdata/openapi/swagger.json", and click "Explore". That would be enough to list your API.

If you want an even faster way to see it in action with XData:

1. Run the demo named SQLiteConsoleServer. It's located in folder demossimple_sqlite. That demo is available when you install TMS XData trial or licensed version.

2. Open web site

3. In the edit box, enter the OAS file address: "http://localhost:2001/tms/music/openapi/swagger.json":

4. Click Explore to browse the API and test.

And that's it!

This new XData release doesn't stop there, there are lots of new features including several new types supported in method parameters, entity properties, PODO properties, and more!

Wagner R. Landgraf


This blog post has not received any comments yet. Add a comment.

TMS Analytics for nonlinear multiparametric approximation of surface data


Thursday, October 05, 2017

The new version 2.2 of TMS Analytics and Physics pack contains the nonlinear least squares approximation tools. The nonlinear approximation tasks are widely used in statistics to fit experimental data with some random distribution function.

Let us consider the example of surface data fitting with the 2D Gaussian function. The Gaussian distribution of 2 variables x and y ( has the following math expression:

Except the amplitude A, the distribution nonlinearly depends on four parameters: center coordinates x0, y0 and deviations sx, sy. The task of fitting data with the Gaussian function is to find optimal values of the four parameters, those minimize the error of the distribution and the experimental data zi(xi,yi), i=1..N.

The approximation task can be solved by the numerical tool with the following code:

  variables, coefficients: TArray;
  f: string;
  basis: TNonlinearBasis;
  cValues: TArray;
  appr: TNonlinearApproximator;
  opt: TSolverOptions;
  eValues: TArray;
  eValue: TFloat;
  variables:= TArray.Create('x', 'y'); // 1
  coefficients:= TArray.Create('x0', 'Sx', 'y0', 'Sy'); // 2 
  f:= 'e^-((x-x0)^2/(2*Sx^2)+(y-y0)^2/(2*Sy^2))'; // 3
  basis:= TNonlinearScalarBasis.Create(variables, coefficients, nil, f); // 4 

  appr:= TGaussNewtonLeastSquares.Create; // 5
  appr.C0:= TArray.Create(0.1, 0.1, 0.1, 0.1); // 6
  opt:= TSolverOptions.Create(true);
  opt.MaxIterationCount:= 100;
  opt.Precision:= 0.2;
  appr.Options:= opt; // 7

  cValues:= appr.Approximate(basis, xyData, zData); // 8

  // use basis with optimal coefficients

Line 1: Create array of variable names.
Line 2: Create array of four distribution coefficient names.
Line 3: Set up the approximation function expression.
Line 4: Create the nonlinear basis instance with specified data.
Line 5: Create the appropriate nonlinear approximator instance.
Line 6: Set up initial guess of coefficient values for nonlinear solution.
Line 7: Set up appropriate nonlinear solution options.
Line 8: Solve the problem (finding optimal values).

When optimal values of the Gauss distribution parameters found, they can be used with the basis instance to calculate the distribution function in any specified point (x,y) or for other analysis methods, like derivative calculations and so on.

On the pictures below there are results of the approximation made with some generated noisy data. The result presented as 1D section of the 2D function for two different x values: x=0.0 and x=0.6.

In this sample, we used the TMS FNC Chart to display the values and the approximated function. The advantage of using the TMS FNC Chart is that it can be used both for VCL and FMX applications and we can use the same code to create a VCL Windows application or a FireMonkey cross platform application.
The source code of the example application can be downloaded here.

The TMS Analytics and Physics pack version 2.2 includes also many other useful numerical tools: linear least squares approximation, 1D and 2D integration, ordinary differential equation solution, function analysis. Due to the addition of array and matrix support in version 2.2, many numerical calculations can be implemented in vector form with small and compact formulae. The version can be downloaded from the product page.

Bruno Fierens


This blog post has not received any comments yet. Add a comment.

TMS Component Pack v8.8 is here


Wednesday, October 04, 2017

What initially started in 1999 as a small bundle of about 15 VCL user interface controls for Delphi, has grown in about 18 years to a set of over 400 powerful and feature-rich components for development of VCL Windows applications with Delphi and C++Builder.
Thousands and thousands of hours work went into this VCL component set that found its way to thousands of Delphi & C++Builder developers world-wide and this way, also to thousands of Windows applications used in so many places day-in, day-out to help and improve the life and work of so many people. As a small example, we learned that our VCL Planner is being used to track maintenance schedules of the French trains all over France, all in real-time.
And yet, every day our team continues to improve, extend the TMS Component Pack, assist the users in getting the most out of it and listen carefully to your needs and wishes. Also with the newest v8.8 release, we focused on user needs and added no less than 11 new features in existing components and 3 new components that were requested. We have our feature request logging & voting system for this where customers can add new feature requests and up-vote feature requests from other users so we can set the right priorities in our development.
As a result of this, these 3 new controls were added to TMS Component Pack v8.8:

New : TAdvHighLightLabel v1.0.0.0 : Label that allows to highlight specific words in the label text in different colors.

highlight label

New : TAdvTouchSpinEdit v1.0.0.0 : Spin edit control with spin buttons left and right from the edit control to allow easy up/down button access from touch screens.


New : TAdvDBListBox v1.0.0.0 : Listbox control with embedded filter + insert data capability that can be bound to a dataset field.


In addition, 11 new features were added to existing components:

Whether you are using the newest Delphi 10.2.1, C++Builder 10.2.1 or still using an older version of Delphi, our TMS Component Pack installer detects the versions of Delphi or C++Builder installed on your system and will install for any version (from Delphi 7 onwards) it finds.
If you haven't used the TMS Component Pack yet, check out all the feature-rich components you have been missing all this time. If you have used an older verison of the TMS Component Pack, check out all latest additions & improvements and if you have just downloaded & installed the latest version 8.8, check out the new components and features that were added.

Now that TMS Component Pack v8.8 is released, we are already laying out plans for the next version and eagerly awaiting your favorite feature requests or feedback that you can send by email, in our forum or add to our feature request system.

Bruno Fierens


This blog post has received 2 comments. Add a comment.

TMS Data Modeler 3 is out!


Tuesday, October 03, 2017

We are happy to announce that TMS Data Modeler 3 has been released today. TMS Data Modeler is our tool to design databases models, ER diagrams, import existing database schema and, among others, generate source code with TMS Aurelius mapped classes based on the database schema. Below is a list of the new features in this release.

Updated User Interface

To start with, we have improved user interface, by using a more modern look-and-feel. A new cleaner color theme is used, logo, file menu, splash screen have been updated.

Customization Script for TMS Aurelius Export

When generating TMS Aurelius classes from database, you can now fully customize the output source code. Users don’t need to manually tweak the source code anymore, or wait for us to explicitly implement an option that changes how source code is created.

You can simply write a script that is based on event handlers. You can for write the following script to add the [Version] attribute to any field named “FVersion” in all of your classes:
procedure OnColumnGenerated(Args: TColumnGeneratedArgs);
  if Args.Field.Name = 'FVersion' then

In case you script gets complex, you can also use a full-feature debugger to check what’s wrong with your code.

For the scripting system and debugger, TMS Data Modeler internally uses our scripting frameworks TMS Scripter.

You can refer to documentation for more info on how you can use customization scripts in TMS Data Modeler.

Export TMS Aurelius classes to multiple units

In previous versions all TMS Aurelius classes would be exported to a single unit. Now you can choose the name of unit where a specific class will be exported to. TMS Data Modeler will even warn you if there are cyclical references between classes declared in different units.

Source code preview

You can now preview the output source code in the TMS Aurelius Export Dialog itself, without needing to generate the source code files to view them. Just click the Preview tab and you will see the final source code generated.

Separate classes into models

You can also define to which models each class belongs to. One or more TMS Aurelius Model attributes will be added to each class. If you already have multiple ER diagrams in your Data Modeler project, then you can optionally ask for each diagram to be considered a different model and have your classes be marked automatically with one Model attribute for each diagram it belongs to.

It’s also worth saying that we have updated a lot of internal processes, frameworks and tools. It took a lot of effort. While it’s not directly perceived by the end-user, it doesn’t reflect directly on user experience, we’re sure that it will make release of newer versions easier and faster.

I hope you are excited with these new features as much as we are, and enjoy the new TMS Data Modeler!

Wagner R. Landgraf


This blog post has not received any comments yet. Add a comment.

Previous  |  Next  |  Index