NXOpen

All

Some people are curious of what is NXOpen and how can we develop for NX.

Well basically there are two different things:

(1) Development of NX Core

(2) Development of NX Customization

NXCore

For the first group, Siemens is responsible for developing the software and therefore hire its own people to do so.

NX Customization

For the customization, in theory any one could do it, by basically using loading the custom project before starting. To do so, we use the NXOpen API, which is actually available for several programming languages: python, c# and c++. The official sources can be found [1]. In fact NXOpen is not a simple API, but a collection of API’s that we can use to build the programs, the API for Python can be found here [2].

Example

As one example, we use the interface #include<NXOpen/NXObjectManager.hxx> to build objects from it or use its functions, e.g. NXObjectManager::Get(tagIterator). It is easier also to use the corresponding namespaces so no mess is dont with functions with the same name.

[1] https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_api/

[2]https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_python_ref/index.html

 

 

TDD

All, Suggestion

 

Test Driven Development is a trend concept nowaways and it’s getting attention even more with the utilization of Python, and its unit test frameworks. I personally use the Unit test framework [1] straight in the command line and sometimes use the watch command to periodically test the code without need to run the script by hand [2]

Steps

TDD is basically divided in the following steps:

  1. Add a test
  2. Add the new test and run seeing if it will fail
  3. Writes the test to pass, i.e. the function that will make it pass
  4. Run again the tests
  5. Refactor the code – i.e. adequate the code to the new needs

Structure

Django

All

When I need to do a fast web site certainly I used Django.

It is free and open-source web framework, which I’ve done several tests and small implementations.

[1] https://github.com/FranciscoMeloJr/Python-Tests

 

Summary of my thesis

All, Thesis

Some people always ask what was the result of my thesis. So below I tried to summarize it.

In one sentece: An automatic method for comparing performance the data provided by tracers/profilers.

In technical terms: We used a non-supervised method, called auto-clustering to group similar performance using profiled data in a data structure. Those groups are compared later and the difference in terms of performance metrics is probably the root cause of the performance issue.

The main part of the thesis was presented in a conference [1].

Methodology

We chose to develop a non-supervised method, called auto clustering. The possibility to use an automated approach is more interesting for us, in comparison with non-automated methods, mainly because we aim not to use data to train the model. Therefore, we implemented a version of comparative k-means using the SSE (sum of square errors) variability information, plus a heuristic evaluation. This technique can be used for an arbitrary number of dimensions, since the amount of difference, SSE (sum of squared error), can be calculated in these cases.

Elbow method
One method to quantitatively measure the number of clusters is the elbow method. This method compares the sum of squared errors (SSE), considering several numbers of groups from the classification used.
The elbow method gives the possibility to use the SSE to find the elbow value, which can be defined as a value at which the SSE changes its behaviour abruptly. In our cases, the elbow value is when the SSE stop decreasing substantially.

However, the elbow method does not guarantee a perfect match in cases where the data is well distributed. Instead, the analysis of the SSE can give a smooth curve and the best value for the number of groups is not precisely defined. In cases like this, we developed another clustering based on the mean distance of the data.

Heuristic Evaluation
To compare the SSE values, we needed also to do a heuristic function which compares the different values of the SSE, to compute the Elbow.

Therefore, we use this approach to compare several runs of classifications and extract the one with the smallest squared errors. The heuristic used is to take an optimal group the biggest gap in an array of SSE values. We use a linear comparision described below speed O(n).
_________________________________________________________________________________
Algorithm for biggest gap evaluation:
Algorithm to get the biggest gap given a sequence of numbers.

_________________________________________________________________________________
      biggest_gap( [sequence]):
          Input:  Sequence of numbers, which are the SSE values
          Output: the location of the biggest gap
           gap= sequence[1] – sequence[0]
           position = 1
           i = 0
while i < length (sequence):
                 if (sequence[i] – sequence[i++] > gap):
                     gap = sequence[i] – sequence[j]
                    position = i
                 i++
           return (position, gap)
            

Association among the Groups

The clustering of metrics is just one part of the approach since a rule of groups needs to be applied to find the specific cause for the discrepancy between the executions. To solve this problem, and find the cause of the difference, we applied a set association rule after the grouping mechanism. Therefore, using a set exclusion, we can find the metric that is responsible for the elapsed time.
The association rule is illustrated in Figure \ref{fig:association}, which describes a metric X and the elapsed time comparison. The grouping on Metric x divides the data into two groups, and those groups are intrinsically related to the elapsed time group. \\
The association rule can be applied in an arbitrary classification algorithm with several different dimensions. Thus, the association can be defined as a heuristic to find the root cause of problems, using grouping or clustering algorithms.

Then we create a matrix of groups correlation can be constructed to better understand the relations among the groups.

Slides

Conference / citation

[1] Performance Analysis Using Automated Grouping Mechanisms. Isnaldo Francisco de Melo Junior, Abderrahmane B. and Prof Michel D. to be presented at the 2018 IEEE International Conference on Software Quality, Reliability & Security in Lisbon, July 2018

 

Qt

All, Suggestion, Tools

Well, during my graduate studies, for developing the C/C++ code I started using Qt and it was the best thing I did.

It is very straightforward, simple and nice. Much less complex than Eclipse Framework, which I also used.

Formally speaking, Qt is this cross-platform framework for graphical user interfaces and applications. It has everything embedded on it and it’s developed by the Qt Company, which I was surprise to learn that was based in Finland.

Qt also provides simple UI interfaces, from which I’m creating the MazelTov framework for testing and analysing performance of open software projects.

I forgot to mention, of course, Qt is also the library that combines several utilities for developers and embedded functions. Qt library is the thing!

 

[pt]

Durante meus estudos de pós-graduação, para desenvolver o código C / C ++, comecei a usar o Qt e foi a melhor coisa que fiz. É muito simples, simples e agradável. Muito menos complexo que o Eclipse Framework, que eu também usei. Formalmente falando, Qt é essa framework cross-platform para interfaces gráficas de usuário e aplicativos. Tem tudo incorporado e é desenvolvido pela Qt Company, que fiquei surpreso ao saber que foi baseado na Finlândia. O Qt também fornece interfaces de interface do usuário simples, a partir das quais eu estou criando a estrutura do MazelTov para testar e analisar o desempenho de projetos de software aberto. Eu esqueci de mencionar, é claro, o Qt também é a biblioteca que combina vários utilitários para desenvolvedores e funções embutidas. Qt biblioteca é a oq ha!

Creating Alias

All

One of the most useful tips for improving performance is to create aliases for the programs that you use more often.

I have done this with several:

Notepad++

Git commands

Explorer.exe

cd [most useful directory]

This is easily done editing the ~/.bashrc file using any file editor. Very straight forward, and then you need to charge the source again, using source ~/.bashrc

 

[1] https://www.hostingadvice.com/how-to/set-command-aliases-linuxubuntudebian/

C++ (STL and Standard Library)

All, Suggestion

I personally think that C++ is wrongly taugh in school because they dont put enough STL and Standard C++ Library. It’s like teaching how to drive a Suzuki Hayabusa until 120km/h, not teaching the full possibility of the engine.

Using STL makes the language so much powerful and  full of resources.

It is actually divided in four main components:

  • Algorithms
  • Functions
  • Iterators
  • Containers

STL is a extremely powerful library which I will post more about later.

 

[1] https://en.cppreference.com/w/cpp

[3] http://www.cplusplus.com/reference/stl/

Dependency Injection

All

This pattern was originally described in Martin Fowler’s article!!

We can summarized it this way: Object A creation depends on another object properties. Therefore A have a dependecy of B. There are several ways to reduce this problem, and B creation is also possible easily using keyword arguments. I dont know why but they always use the engine/car example.

Interestingly to remark that for python it is debatable a useful pattern actually.  But there are many micro-frameworks and tools for python [5].

Links:

[1]https://en.wikipedia.org/wiki/Dependency_injection

[2]https://martinfowler.com/articles/injection.html

[3]https://github.com/ets-labs/python-dependency-injectorhttps://pypi.python.org/pypi/dependency_injector

[4]http://python-dependency-injector.ets-labs.org/introduction/di_in_python.html

[5] https://pypi.org/project/dependency_injector/

 

 

Online compiler – OnlineGDB

All

[en]

When I need to do some small tests I use as online compiler: Online GDB. At least for C++ interface is straighforward and simple and I liked it. It is not that different from many online compiler interfaces, but I personally use this one.

Link: https://www.onlinegdb.com/online_c++_compiler

[pt]

Quando eu preciso fazer alguns pequenos testes eu uso como compilador online: Online GDB. Pelo menos para a interface C ++ é simples e direta e eu gostei. Não é tão diferente de muitas interfaces de compilador online, mas eu pessoalmente uso este.

[fr]

Lorsque j’ai besoin de faire de petits tests, j’utilise comme compilateur en ligne: Online GDB. Au moins pour l’interface C ++, c’est simple et rapide et je l’ai aimé. Ce n’est pas si différent de nombreuses interfaces de compilation en ligne, mais personnellement, je l’utilise.

Using Gitbash/Usando Git bash

All

[en]

For people that prefer a unix like command line interface, Git bash is very recommended.  It interfaces also git program and it is a Linux-based command line. It emules the sensation of navigating in Linux but using the Windows system.

The tutorial from [1] is extremely useful for installing and learning Git bash.

http://www.techoism.com/how-to-install-git-bash-on-windows/

[pt]

Para pessoas que preferem uma interface de linha de comando similar ao unix, o Git bash é muito recomendado. Ele também programa git e é uma linha de comando baseada em Linux. Emula a sensação de navegar no Linux, mas usando o sistema Windows.

[fr]

Pour les personnes qui préfèrent une interface de ligne de commande unix, Git Bash est très recommandé. Il interface aussi le programme git et c’est une ligne de commande basée sur Linux. Il émule la sensation de naviguer sous Linux mais en utilisant le système Windows.