September 27, 2022

From a referee based evaluation to parametric cost maps

 A referee is a instance in sports game which evaluates the behavior of the players. The referee isn't part of the game but his task is to judge about how well the player performs in the game. A typical situation is, that the referee decides if the ball has entered the goal.

The limit of a referee is, that his role is static. A referee for soccer is judging with a different ruleset, than the referee for basketball. In one of the game it is allowed to touch the ball with the hand while in the other not. In a more flexible general game, the referee is allowed to modify the rules during the game. In such a hypothetical game the referee is allowed to change the game. He can advice the same players to behave like soccer players, basketball participent or any other sports game.

Such flexible role switch doesn't make sense for real sports game but it might be interesting in the robotics domain. The idea is, that a robot isn't playin a certain game, but the robot has to obey to the referee. And the referee can say that the ball should kicked in the left goal or into the right goal. And which action is correct doesn't depend on the game but on the decision of the referee.

In such a use case, the referee has much more power than in a normal sports game. So it is no longer a classical sports game with fixed rules, but it is some sort of training game in which the coach imagines the rules and the player has to fulfill them.

From a technical perspective such interaction can be modeled with a parametric cost map. The objective for the critic is to provide a cost map which can be adapted while the objective for the actor is to minimize the costs in that map. The natural commands formulated by the coach are translated into a grounded cost map and the cost map judges if the actions of the player are right or wrong. Such universal game is only limited by the ability to imagine a cost map. And the ability of the actor to parse the cost map.

The term actor critic was introduced already and it describes very well the division of tasks. One instance imagines what the cost map is, while the other instance has to provide concrete actions. It is important to know that both instances are needed so the artificial Intelligence can't be realized with a single module but at least two different modules are needed. The easier to realize module is for sure the actor instance. A computer program which gets a cost map as input is a normal numerical solver. The objective function is provided as input and the task is to search for a node in the game tree which minimizes the costs. A concrete algorithm would be a depth first search algorithm which is described in most entry level computer science text books.

The more complicated problem is located in the coach instance. The critic has to invent a cost function in a way, that a computer can understand it. For example a command like "kick the ball into a goal" is too vaque. The average computer doesn't know what kick, ball and goal is about. So a more precise constraints formulation is needed.

Programming in C# on a Linux desktop

Since many years, the Linux community is asking how and when the Linux desktop will become a mainstream ecosystem. The answer is always disappointing, that this is not the case and nobody knows the reason why. The underlying reason isn't located in the technology but it has to do with the Open Source ideology which prevents that Linux will become the default desktop PC.
Let us investigate the subject in detail and ask a simple question: which IDE (programming environment) is available under Linux which allows to program in the C# language? Somebody may argue, that this question is not important because nobody likes to do so, and in addition all the major IDEs are supporting of course all the programming languages. The surprising insight is, that this is not the case. Let us take a look on some major IDE in Linux which are code:lite, code:blocks, kdevelop and netbeans. It is possible to use these IDE for any language e.g. php, python, C/C++, java and even Lisp. So it would be naturally, that the major C# language which in the top 10 of the TIOBE index is supported as well.
According to the forum postings this is not the case.[1][2][3][4] The interesting situation is, that the answer for C# support or maybe a simple third party plugin is always answered very short with something like “nope” and “we don't have it and there is no plan in that direction” without giving a further explanation. The only IDE which is available for Linux is Eclipse which has at least a third party plugin for C# ("aCute"). But it is poor documented and the user is encouraged to not use the language at all.
So the question is, why is C# not liked by Linux enthusiasts? At first, we have to make clear that Linux is open to different programming languages. All the important languages like C/C++, java, php, python, TCL and of course Forth are accepted and it depends on the individual programmer if he likes the language or not. The only exception is the C# language. Here, the user is not allowed to use the language. The only way in doing so is to install a complete different IDE. That means the user has to leave the normal IDE community and search for a visual studio like software which is available for Linux or not.
References
[1] Feature Request - C#, 2016 #1448 https://github.com/eranif/codelite/issues/1448
[2] Does CodeBlocks support C#, 2014 https://forums.codeblocks.org/index.php?topic=18740.0
[3] KDevelop C# Language Support?, 2016 https://forum.kde.org/viewtopic.php?f=218&t=136944
[4] C# in Netbeans?, 2010 https://www.codeproject.com/Questions/85177/C-in-Netbeans

September 20, 2022

How to solve AI problem with a computer?

 

The main problem with today's computer which includes the software as well is the architecture was designed to solve existing problems. This is an advantage for problems from the domain of mathematics and database but it is at the time a bottleneck in the domain of Artificial Intelligence.
Let me give an example. Today's computers are great for storing table with numbers on the hard drive. The reason is that modern computers have an endless amount of hard drive storage and they have operating systems and database program to manage the information. The same technology failed for handling robotics problems. Even very powerful databases which are running on a supercomputer can't control a simple maze robot which has only 2 sensors and 2 motors.
The problem with AI problems is not how to solve these issues, but to formulate first the problem. AI has nothing to do with databases and surprisingly it has nothing to do with algorithms. The consequence is, that it is not possible to use database programs, programming languages are operating systems to address the issues. Unfortunately, the amount of remaining techniques is little or even zero so the question is how to research AI problem at all.
What we can say for sure is, that Artificial Intelligence has mostly to do with the grounding problem. Grounding means how to convert the real world into a computer representation. Some terms in the context of grounding are: cost maps, notation, motion capture, semantic representation.
None of these terms is located in the classical computer science but they are dedicated AI terms. The shared assumption is, that the world is converted into a data structure, and a cost map or motion capture will help in this task. 
The term "Cost map" is very complicated to explain because it bridges the reality with computer science. A cost map can be realized as a data structure and needs some sort of algorithm to process it, and at the same time, it has to do with a robot which is moving in a maze and with obstacle collisions. The same two perspective situation is available for motion capture which is also a computer science topic and something which has to do with the reality.
The symbol grounding problem is an intermediate layer which combines computer science with reality perception. It is a trick how to explain to a computer what the objective is. From a computer science perspective, a cost map or a mocap recording is a trivial task. In both cases it is stored in a integer array which is not very big. Normal database problems are more complicated to realized than a csv file for mocap recording. On the same hand, a mocap recording can be called an advanced technology because it is very new. It makes sense to summarize these efforts under the term Grounding problem. Grounding means usually to convert the reality into computer science. It is about storing costs and other heuristics in a data structure.
The reason why the subject has to do with Artificial Intelligence is because after a domain was grounded it is surprisingly trivial to solve it with a computer. Every computer built in the last 40 years is able to search in a cost map for the lowest costs and the underlying algorithm is the same what is known as A* which is some sort of mainstream algorithm in game programming.

September 18, 2022

Creating GUI apps in Linux

 A common question for programmer newbies is to ask which of the existing GUI frameworks is the most widespread used, or the easiest one to learn. Other users may ask which programming language might fits well for writing large scale GUI apps. The surprising situation is, that none of the existing libraries like Qt, tkinter or WXwidget can be recommended and all the mainstream languages like Python, Java and C++ are an antipattern to develop a GUI app.

With this forward it might be interesting to know what the preferred choice is in writing a GUI app. The working hypothesis is, that not a certain programming language is important but a certain GUI builder software. A gui builder is a WYSIWYG program which allows to drag and drop a GUI interface similar to painting an image, and then the code is generated by the program.

Let us take a closer look what very different software tools like MS-Access, Borland C++ Builder, code:blocks and WXglade have in common. In all these environments, the user isn't asked to write a single line of code, but he has menu with widgets like a button, a textfield and a combo box and then the tool knows how to write the code.

The reason why a gui builder is not optional but mandatory is because a GUI framework like Qt or any other one is a large scale library which contains of thousands of classes. It is not possible to use a small gui library. Even so called lightweight GUI libraries like FLTK will occupy around 4 MB on the hard drive and provides endless amount of options and parameters. The only way to master all the widget is an extra tool which is not working with sourcecode but with a graphical interface.

Let us take a closer look into a smaller but very powerful GUI builder which is wxglade. The amount of features is very low. The user sees in the left pane the list of widget and is asked to drag and drop them into the right pane. The interesting situation is, that in setting menu for the entire application it is possible to specify a concrete programming language:



The menu looks not very impressive,, it is only a dialogue box with the option for C++, python, Perl and Lisp. The interesting situation is, that at least the wxglade software knows how to convert a GUI window into runnable sourcecode.

Let us investigate what will happen after activating the "C++" option. The wxglade software is producing the .cpp and the .h files. Also it is written in the preface in the comment section how to compile the .cpp code into a binary file. The user has to enter the command into the terminal and gets the application. A simple example Hello world windows contains of a text widget and a button occupies around 164 kb in total and can be executed with "./MyApp". It is a normal C++ program written by a machine.

After creating the code, the human programmer is asked to improve the generated code. He can add some events or program the database backend by itself. The interesting situation is, that such a workflow is much easier than writing the app from scratch. The assumption is, that 100% of the C++ GUI apps are written in this programming style. In all the cases, the beginning is always a GUI Builder which produces some code, and this code is improved more or less by a human programmer into an application.

This pipeline makes sense because a simple form which contains of only 3 buttons and some widgets will result into a long class which has 200 lines of code. It is not possible or very complicated to write the code by hand only with a printed manual. This is only possible if the programmer knows already what a concrete programming language and a concrete GUI framework has to offer.

Perhaps it should be mentioned, that all the generated code from Wxglade is using the Wxwidget. Somebody may argue that wxwidget is not the best framework and this assumption is correct. But, suppose a different gui builder will use a different framework, for example Qt. Then the pipeline is the same. At first the programmer starts a GUI builder, the code is generated by the software and then the programmer improves the code a bit or more. So we can say the focus is always on a gui builder which stands in the center and a concrete programming language or a concrete GUI library is less important.



In case of GUI programming the question is not if C++ or Python is the better choice. And the question is not if Wxwidget or Qt makes sense. But the more serious question is, if Visual studio, wxglade or Eclipse is a here to stay. GUIs are developed with a certain GUI builder, the gui builder defines how the sourcecode will look like.

There is some sort of TIOBE Index for gui builder tools. Popular tools are visual studio, eclipse and android studio These programs are not used because of syntax highlighting or other text editor capabilities but the dominant reason why programmers are using Visual studio is because of the GUI builder functionality. It allows them to draw an application similar to draw a picture with a graphics program.

GUI builders
The most interesting feature of a GUI Builder is, that it interprets the world from a certain perspective. There is no need to decide for or against a programming language. For a gui builder the difference between C++ and is low, even both languages are very different from each other. The reason is that a gui builder doesn't asks the user to type in sourcecode, but the user has drag & drop widgets and press the "generate" button.

The reason why most GUI apps are developed for Windows is because the visual studio software is a mature one which is over 20 years old and its core component is the mentioned gui builder. Alternative tools like wxglade have less features and are less well documented.

The interesting situation with visual studio is that the software can be used to create C++ and C# code as well. So the question is not which of the languages is the better one, but the GUI builder works fine with both.

Even if GUI builders are highly important in software development they are seldom discussed in the literature. The assumption in the past was that it depends on the individual choice of a programmer if and which gui builder he prefers. Also the tools are nearly invisible in the final sourcecode, because what is available as sourcecode is written in a certain programming like C++ or java. So the assumption was, to focus on the language or maybe on the GUI library but not on the tool which is responsible for the code.



[1] https://visualstudiomagazine.com/articles/2017/08/15/ide-ranking.aspx




C++ is a great programming language

Modern application development works with the attempt to create web applications and use prototyping techniques. Both is supported very well by the C++ programming language. C++ is a scripting language and it was designed for the Internet. C++ runs great in the browser as a GUI Frontend and on a webserver as a database backend.

But c++ has many other features which makes it unique from potential alternatives. C++ doesn't require the user of pointers which are known as a complicated programming tool which even aren't understood by experts. Also it doesn't have header files which are known as error prone in the C language.

IN the sum, C++ is the language of the future which is recommneded for most purposes. It is a beginner friendly prototyping language which fits very well to the needs of newbies.

September 06, 2022

Creating a minimal outliner in Linux

 



For creating a 1dArrayoutliner a first mockup is available.It was realized in 200 lines of code in the python language and shows the main window for an outliner. It is using a two pane layout. The user can select in the left menu the page and will see in the right pane the content of a page.
The page content is rendered with a self written parser. A pushdown automaton analyzes a markdown file and translates it into a rich text window. Right now, the GUI framework is wxpython but it seems that it is not powerful enough. So perhaps it makes sense to switch to tkinter?
The bottleneck of the current project is to save the information from the text editor into a markdown file. To realize it the text editor needs the abilty to save something as markdown, or the program needs to parse the information in the window manual. The task is needed because images and text are shown at the same time in the window.
That means, writing a text only outlier program is pretty easy, but if the images are shown inside th text it is much harder to program it.
 
Perhaps it makes sense to explain why there is need to program yet another outline editor. Because most of the programs from the past are very big projects It seems, that the average outliner / PKM software has at least a size of 1 MB and there is no upper limit so that current software has 200 MB and more.
The idea is to reduce the requirement to a minimum and write a much smaller outliner program which has 100 kb and less. For doing so there is need to specifiy which features should be implemented and which not. From a database persective an outliner has to implement the CRUD operations which stands for create, retrieve, update and delete. The interesting situation is, that more actions are not needed, if the user can add new pages and modify the existing he is happy. Editing a page means usually to enter text in the richt text window which includes adding images. I think it is not possible to ignore images and assume that a text only outliner will fulfill the needs of a user.
 

September 04, 2022

Review of the new Version of the Zim wiki

 

The latest version of the Zim desktop wiki is 0.74.3 which is not available in Debian. But the user can download and install the package manual with the dpkg tool. The first impression of the software is very good. The programmers have removed the toolbar, so that it is no longer possible to format something in bold Also the search box was removed The user needs an additional click if he likes to find something.
Some things remain unchanged. The rendering of the link map takes the same huge time like in the stable version. The user is pressing the button, has to wait for 20 seconds, then a popup menu from gnome asks to quit the application at all and then after a while, a messy chart of the nodes is drawn.
One cause of the slow speed is for sure the underlying programming language. Python is known as a beginner friendly programming language which is not recommended for productive software. So it is some sort of luck, if the user doesn't loose all the important information, if the program is crashing.
A closer look into the source code will show, that the Richtext WYSIWYG editor was realized in 600 kb of Python code. Most of the code was written a while ago in the Python language and never changed. This speaks for the zim project. There is no need for using the C++ language or creating a more efficient GUI because this would need too much manpower which would be missing somewhere else, outside the zimwiki project.
Overall the zim wiki is a great improvement over the previous version 0.73.5. If the end user is not satisfied with existing Outliner tools, he will dislike the zimwiki program as well. It is a pleasure to see, that even an ArchLinux package file is provided. This Linux distribution is a great replacement for Debian and other outdated projects because ArchLinux has always the newest version of a program ...
One bug should be mentioned at the end. In contrast to the previous version, the program is asking the user if he really likes to delete a certain page in the list.

September 02, 2022

Writing GUI apps for Linux

 

GUI applications are a major concern in the Linux ecosystem. There are some frameworks available but none of them can be recommended. The following blogpost introduces the topic and compares the major options for programming window based applications.
Roughly spoken the list of gui frameworks consists of: Qt, gtk+, wxwidget, tkinter and FLTK. THe problem is, that the programmer can decide only for one of the frameworks. One the first look, Qt looks like a mature GUI framework. There are some points which are speaking against Qt. First thing is, that it is not only a C++ library but it extends the C++ language. Second problem is, that the amount of commits in the qt project is 5x lower than the amount of commits in the gnome project. And third point is, that larger LInux distributions like Ubuntu are preferring gnome.
Suppose gnome is a here to stay, the next question is how to create a gui. The first assumption is, that the underlying GTK+ library works pretty well to create guis. THe problem is, that gtk is documented poorly and even under python it is complicated to create a gui app. The better choice is to use the wxwidget framework.
Wxwidget looks the same, what PC users are using under Microsoft windows. It is full blown framework to create gui apps. It is working with python and C++ as well. The major concern against wxwidget is, that the size for an executable hello world app is too large. Indeed, a hello world app will need around 140 kb size in the working directory. And the app is doing nothing but showing a window with some pull down menus.
On the other hand it is possible to reduce the filesize with some tricks to around 22 kb:
g++ -Os -s helloworld.cpp `wx-config --libs --cxxflags`
upx a.out
Also it should be mentioned, that under the Windows operating system a much larger file size for hello world apps is common.
Compared to the wxwidget library, the FLTK library looks very outdated. Only a few tutorials are available and it seems, that the development has stopped around 2010. So the best choice for creating in the year 2022 a Linux gui app is wxwidget.
MVC concept
After deciding for one of the existing frameworks the next question is how to create the GUI app itself. Suppose the user has decided for the wxpython framework which allows to create GUI software in python, how exactly should the program look like? The major problem with GUI application is, that the inner principle is different from normal object oriented programming. OOP means basically to create objects for each elements. So the assumption of the newbie is, that he will needs different objects for the menu bar, the text box and the buttons. This is correct but wrong at the same time.
The major problem is gui programming is to connect these elements together. The end user will click on a button whichi activates the script and the script is searching something in the database. The problem is, that these process is executing functions in different parts of the program. So the question is how to arrange the classes.
MVC is a here to stay principle in solving the question Let us describe the concept step by step. The first file which has to be created is gui.py. This file holds the form which is displayed on the screen. It contains of the menu, the entry boxes and the buttons. Such a gui.py file can be created either with a text editor or with a gui designer like wxglade. After executing the file, the user will see the GUI on the screen which is a mockup. It won't do anything but show only the graphical frontend of the program.
In the second step two additional files are created which are controller.py and backend.py. The controller.py file contains of the event handling. It is the same what is known in Visual basic and MS-access as macros. For example, the user clicks on a button, and then the script in controller.py is executed. The script checks if the input is valid and decides which function should be called next. In the easiest case, the user is pressing on a button and then a “print()” statement is executed which displays on the command line that the button was pressed.
It is important to know that the macros, aka the eventhandling is never located in the gui.py file but it is outsourced into the controller class. This is the opposite of normal object oriented programming. Because of this reason the principle is called Model view controller principle. It is a technique how to write GUI code into different classes. The reason why MVC is used by 99% of the software is because it allows to create GUI apps much faster. The idea is, that in the first step only the GUI mockup itself is created. That means, the window on the screen has no functionality. The functionality is added later.