Monday, June 22, 2015

Facts versus Models

Intro

Have you ever participated in an argument where countless points being raised from both sides don't change anyone's position? Each consequent attempt to convince an opponent makes you look deeper and deeper into what would make them think different from you. Eventually, you may find out that some very basic perception aspect is different. A good outcome would be one of the sides (or both) figuring out the imperfections of their model (of the subject domain) and making corrections internally, resulting in a consensus. As you see, the argument is a collision of different models, and the facts are shots fired from each side. A fact/shot can be either explained/deflected by the the receiving model (shield?), or it hits hard, exposing the model inconsistency. This, in turn, is my model of an argument process, and you are welcome to argument about it.

In the past, I've followed the facts as anchors binding our fuzzy reality to objectiveness. Whenever listening to someone, reading news, watching a show, I used to always search for the facts, extract them, and process with my models of understanding. Consequently, anything based on the believe didn't make sense to me, like religions or propaganda. Lately though, my perception focus changed from facts to models. Instead of matching the facts to my models, I started constructing images of other models and evaluating them as a whole, using facts at hand for quick verification. This is my new meta-model of perception, and I'd like to register it with this post. I'm going to analyze facts and models in general in an attempt to explain the meta-model to you.

 

Fact

Simple. One can explain a fact in a single sentence, like "it was raining for 2 hours yesterday". It is universally understandable. It's on the lower level of understanding, way below opinions and feelings, thus being totally neutral in its message.
Manipulative. A single fact is harmless, but they always come as a bunch. Supposing I showed you another planet with life forms, and all 25 of them that you've seen were white. Would that make you think all of them are white? What if I was selecting them manually just to make you think they are all white? By filtering the facts you may change the way people construct their models, and social media has been doing this for ages. One would say the filtered fact set is "incomplete", but what would qualify as complete here anyway? It's a tough question, and my answer is - the model defines completeness, being part of the reason it's so important.
You don't have to lie to steer people's minds. Next time you see (on TV, newspaper, etc.) angry people oppressed by their country leaders (with lots of natural resources), supposing you consider it a fact (see the elusive section), ask yourself questions: do these people represent the majority? would you be able to show angry people in your own country? and why they are not in the news then? etcetera.
Elusive. What is the fact anyway? Was it raining for 1h58m yesterday, or where exactly was it raining? Maybe the rain clouds moved over this time, maybe it was on and off, maybe it was just reported as raining but nothing actually happened. You may try to dig these details infinitely, and there will always be some rough corners remaining. We don't exactly interchange facts, these are just little models approximating some experience, not always valid ones. So, you can't catch a fact, it's elusive. We often agree on facts because they are being generated by a common model, common sense if you will, but it barely pretends to be more objective than any other models we exchange.
When you hear the report of a passenger plane being shot by X, ask yourself one question: does it fit into your model of X, or is it a part of transmitter's model? What is the "fact" based on: a quality video of the event, or just the words of an involved party? What could have happened that would be perceived the same way?
Useless. We can remember the fact, transmit it (a model of it, to be precise), but that's it. Actually learning from a fact involves something much more complex - a model, explained in the next section.

 

Model

Smooth and extendable. Model is what allows us to predict the future, and to fill gaps in our past. This is how the brain works - essentially, it constructs and manipulates models of the perceived world. Prediction is the sole purpose of our high-level neural system.
A historian, for example, reads the "facts" about German history, tries to construct a model in their head, including the psychological profile of Hitler, if you will. When they finished the model, checked that the facts matched (or buried the ones that did not), exchanged the idea with other historians, applied the political agenda, only then they write a book explain every little bit of what happened. The model is often hidden behind the straight facts: it's in their formation, layout, and, of course, selection (if you know a bigger subset).
Contagious. As mentioned before, we exchange models and not facts. Once you understand the model, it changes your perception of the future by proposing difficult predictions of it. Often, you'd want to adopt a model to live in a better future.
In the last century there was a couple of strong contagious models: capitalism, communism, and fascism. The first envisioned goods and freedom for everyone, the second - equality and modesty, and the third - prosperity at the cost of other nations. People fought for these ideas all over the world (WW2, Vietnam, Afghanistan, Korea, etc.), by the way constructing enormous mechanisms of spreading the idea far away (mass media, culture of journalism, generations of kids educated in a biased way, etc.). Today we read the history books written by the winners, we listen to their voice adjusted to continue zombifying us, this time only to different threats.
Complex. A model is an essence of all the facts it explains. It bears the core complexity of the domain, which can be extremely valuable. It is often complex to explain it to others, especially if it hasn't shaped up nicely yet in your own brain. These qualities make it important to always serialize the important models, which is what I'm doing here.

 

Conclusion

Pay attention to the models around you, don't focus on the facts. When thinking about a person, or arguing with one, try reconstructing how they see the world, so that it matches the actions they perform. Be ready to test your own models and be flexible to adjust them. Be skeptical about "facts" being streamed to you, try correcting them with respect to the bias of the transmitter. In a way, there are no facts, no truth, and all we got are subjective models.

Monday, January 19, 2015

Social Architecture 2: freedom of expression


Part of the reason of USSR failure was going against human nature. The ruling party tried to standardize everything: how people speak, what they wear, sometimes even what they think. That contradicted with human desire to create something new, to differentiate from others, to find oneself style and identity. People were jealously looking at the West, scrambling whatever bits they can get from there (jeans, VHS players, gums anyone?). This was a huge contributing factor to the crash of the empire: people wanted to be liberated.

Capitalists, on the other hand, played upon human psychology instead of fighting it: they understood the basic human needs and they pushed them above the initial meaning. Capitalists created *new* needs, and this is still how our market evolves (take any Apple product as an example). Remember what they say in business "If you are competing, you've already lost"? Now think about it again, now within the context of consumerism culture.

Now, back to USSR. The reason soviets unified everything was not only the need to control the crowd. It was also the most efficient way to manage available resources (manufacturing, materials, work force, etc). In a sense, this was a real *economy*, while capitalists were not concerned about it on the global scale. The interesting bit here that I found is that Communism in general does not require unification, it was just a technical limitation in this particular implementation.

Imagine a city of the future again (say, the Venus Project). People share everything they can (outside of their rooms). There is freedom of thought, because there of no need to control everyone: people are self-organized, and most decisions are made by a smart computer program. There is freedom of style and expression, because everyone can design their own appearance, or a commodity, and 3d-print it, thus making the design instantly available to anyone else. What happens is the advanced computing and manufacturing technologies allow us to express ourselves while still preserving the earth resources.

Concluding, it just wasn't the right time for Communism to be adopted. We needed to transit from the industrial to informational era. We needed the Internet, computing power, 3d printing, and other key technologies to be developed in order to build the new order. *Now* can be the right time. Delay half a century longer - and there will be nothing to save: our irresponsible treatment of Earth will change the atmosphere and the biosphere to the point of no return. We need to stop consuming and start thinking: about how we live, where we live, and what we can do to sustain ourselves.

Saturday, December 13, 2014

Social Architecture

Human civilization has reached unbelievable power. We process petabytes of information, our eyes reach the furthest corners of the universe, while our minds dissect the finest structure of matter and energy. We are incredible species, but we really don't know how to live side by side on this planet and cooperate efficiently.

Some long time ago, our ancestors figured the concept of money. It's an artificial value used to exchange everything else with. Many of our needs can be achieved by having enough money, and we work hard to get them. Then we group into corporations - these giant money-hungry monsters with resources and power. They produce spaceship parts, they grow our food, they even teach our kids. The problem here is that they don't care about result quality, environmental concerns, and morality of their actions (think mercenaries) as long as they get the most money of it.

On the other hand, we are supposed to consume more and more for the economy to develop. Being a target of aggressive advertising and manipulation, today's adult needs a big house, 2 cars, a mobile phone, a tablet, a laptop, and 120 fashion ties in his wardrobe. If you provide these commodities to everyone, you'd realize it requires more resources than our Earth has.

In essence, money divide us. We can't efficiently work together, because money is the strongest link we have. We have organized ourselves in an unsustainable, inefficient way of life. Both present and future pose many challenges to this system:

Robotization. Modern factories are mostly self-operated. More and more human activities become outdated with the development of robotics and expert systems. Self-driving cars, for example, already on the roads, hence all the taxi/truck industry is on a timer. Eventually, humans will only be needed to operate the robots and serve each other. There will be a shortage of jobs on the market and an ever-increasing demand. Money will concentrate in the golden 1% of the society, which controls the robots and other people, thus making the rest to be slaves.

Natural resources. Our industrial revolution was made possible by the abundance of fossil fuels. We've advanced a lot, but still haven't figured out how to live in a sustainable way: fossils are limited, and the amount of energy needed to dig them goes closer to the energy it produces. We need a focused effort to develop alternative energy sources and migrate our infrastructure to be independent of the fossils. I don't see this happening at the moment, either from the governments initiatives or the corporations.

Government. We may have a vote on who is in charge, but since the government is a part of our socio-economical system, it becomes corrupted by money. Big corporations are actively (even openly) lobbying their interests, supporting candidates, and pushing their interests by any means possible. At the end of the day, the government becomes a middle-man between consumers and corporations, the goals shift, and the status quo prevails.


Beautiful Earth. Why should a corporation care about the global warming? Or that weird species of birds that can be found only in New Zealand? Or about preserving the rain forests in South America? But it's not the corporations fault, nor of its people, it's how our system works. This planet will not be able to bear with us for much longer. We pollute air, throw radioactive wastes into water, killing the living ecosystem that was established long before us.

War. War never ends. We fight for resources, for influence, sometimes just because we produce too many weapons. For some groups, war is a profitable activity, and igniting a conflict becomes their natural goal.

Health care. Imagine a cure that is accessible all over the world, costs nothing, and is able to treat all known illnesses. If such a cure is ever found, there are two possible scenarios: 1) it becomes destroyed with all the evidence, because it is not profitable; or 2) it's starts being sold to selected people only with sky-rocketed price. Health corporations are not interested in healing you quickly and efficiently (it may be a side goal, or it may be not), they are interested to suck more and more of you while you are sick. Their best interest is to charge you a ton of money, keep you for long in the hospital, and prescribe you the pills that would never help, if not make it worse.

Education. Surprisingly, the best teachers that we remember from our school days are the ones we never liked while being there. They were harsh, unforgiving, and caring only about you getting important skills and knowledge. Private education institutes are doing the opposite: they want you to like being there, they advertise heavily, and they try to convince you that the money were worth spent. Actually teaching you becomes a side effect. As a result, we get generations of worth-less over-confident individuals, who do not contribute much into our society.

Unstable economy. The flow of money does not exactly self-regulates. The free market is controlled by the laws of supply and demand. There is a lot of intermediate entities between producers and consumers. It's venture capital firms, mutual funds, stocks, global importers and local retailers, to say the least. On one hand, they naturally occur in the system of free market. On the other hand, their only job is to eventually connect consumers with producers. Naturally, they become parasiting on the system, resulting in the most powerful and rich people being them, who controls the money flow.


Better organization 

An alternative organization model is described in the Zeitgeist movies. Basically, we need to change the established value system in order to live more efficiently. We need to throw away money, strip ourselves of power, and integrate all layers of the society in a centralized manner.

Venus project is a good example. It's a self-sustainable city with no private sector, where everything belongs to the citizens. It is controlled by a computer program, which can be developed and maintained in a collaborative way. The program can efficiently distribute resources and energy, schedule manufacturing and farming throughout the whole city.

The biggest challenge is to change the motivation of people: instead of working for money, they need to work for contributing into the society, or because they simply like doing something. With todays technology, we can have most non-interesting and monotonic jobs being completely automated. Surprisingly, small communities organized in a similar manner can already be found all over the world. People are happy there, because they see apparent positive effect from their activity instead of just a pile of money as a measure of their contribution.

The change is difficult for a single person, but not so much for the whole society, because it can be achieved in an iterative manner. A group of people may unite, behaving in the "old" world of free market as a single entity. More people may join the club, build facilities, expand the farms, thus eventually unwrapping into a city. Cities may connect with each other and be sustainable without a direct intervention from the outside world (think: global warming or a world war). Of course, the ultimate benefit of this organization would only come when the whole world converts.

One can find a similarity to communism with all the possible negative associations. As an idea, communism didn't fail in XXth century. It's the implementation that failed, and this should be expected from the first rough attempt to change the social organization. The technologies weren't ready yet, and forcing people into the new system caused a lot of backslash. All in all, USSR was a world-scale experiment, which had it's moments of great glory, even though it broke eventually.

Concluding, I may have not convinced you to drop all your belongings and move into the nearest community village... But I hope my words raised your interest in the alternative socio-economical systems. I hope you'll start wondering about the laws around you that were invisible just because we are so used to them from the birth. Perhaps, you'll start seeing bad things of our world to be a little less inevitable. You may see the light of actually fixing our society at some point.

Update-1. Found this wonderful post highly correlating with my position. Must read, if only you can get through the blue background ;)

Sunday, October 5, 2014

Circles of the Home Automation hell

Introduction

Just a week ago I knew nothing about IoT. All the buzz was meant (I thought) for someone else, but that changed when I bought a house. Suddenly, a strange desire was born in my mind: to connect entities (doors, rooms, speakers, etc) inside my house, to monitor and control them as a system. Thus, I started looking into Home Automation, and with each new iteration I was diving deeper and deeper into the hell of technological diversity.

 

0. Complete Solutions

There is a lot of companies (like this one nearby) offering to install their proprietary home automation system for a big sum of money on the case by case basis. That wasn't acceptable for me, because I wanted to know what my options were, and expand gradually.

 

1. Isolated subsystems

Some companies specialize only in a specific domain. For example, Lutron is known for its lights and dimmers, which come with remotes. Phillips Hue makes the best LED lights, also remotely controlled. Nest is a decent (and awesome looking!) learning thermostat. Going wider, Vera allows you to buy components that you need and attach them to the system dynamically. Naturally, I started asking myself why these things can't be organized together, what language to they talk to each other?

 

2. Wireless Protocols

It turned out, there is a lot of diversity in wireless means of communications. You thought that WiFi and Bluetooth are enough for everyone? Welcome to the real hell:

ZigBee - perhaps, the oldest protocol (outside of X10, which we'll skip). It's looking decent on paper: support for mesh networking, low power consumption, huge group of supporters. It is ISO certified, and you can find numerous open source libraries and protocol implementations. However, the devil hid in the details, again. There are two incompatible kinds of hardware: Series 1 and Series 2. There are different profiles of communication, and you can't easily mix and match those. Finally, I tried to look for something specific, like a temperature/humidity sensor, and it came short of options for the real "Buy" button to appear. It appears that Zigbee has some fundamental issues (maybe those I mentioned) that pushed the alternative developments.

Z-wave - the most available (in terms of hardware) protocol, which also claims to be very smart in design (mesh networking and such). It is really straightforward to find actual devices, but unfortunately difficult to program them: the API is opened only after buying the SDK and signing an NDA. Open-source implementations exist but seem to be rough and incomplete.

EnOcean - the european-origin protocol with the main focus on self-powered devices. There is not much out there to read about it, but the limited range of compatible devices is available from a single manufacturer. The promise of battery-less components seemed very appealing, but it got compensated by the price of those.

Other things I didn't research include Insteon, Bluetooth Smart, WiFi (for IoT), ClearConnect (used by Lutron), and Thread (used by Nest). The last one seems exceptionally promising, but no public information is available yet about it.

At this point, I realized that if I'm gonna control my devices, they had to use the same protocol. Alternatively, I found a market of cross-protocol universal hubs, such as Wink, Revolv, Staples Connect, and SmartThings. While they do allow using devices from different networks, I found only Wink providing an actual API, which I doubt works flawlessly. If you don't intend to be in full control, this may be your last stop (for good).

Another problem, adherent to most solutions, is the requirement of Internet access. While I do appreciate a mobile app to access my home system, I believe it should not involve a cloud server. The cloud is a privacy hole and yet another point of potential failure. My system should be as much self-contained as possible.

Thus, I wanted to go deeper... The hub, I imagined, could be a headless Raspberry Pi with a RF module (like XBee) that I'd program myself in Rust. Fortunately, Pi supports modules for all major RF protocols. The hub would host a website for online access and schedule my house in a 24/7 mode. The only problem was locking into a single protocol (and its API), because I didn't want to hook up and dig into multiple protocols at once.

 

3. Micro-controllers

I noticed that sensors without RF modules are very abundant and cheap. What if I connect them to my own network physically, by having a micro-controller and a RF module attached by hands? That perspective made me look into simple computing cores:

Arduino - the most known family of boards, featuring dominantly the AVR family of controllers. Sadly, LLVM (and hence Rust) does not support this platform as a target, and the cheapest ARM core (Arduino Due) is more expensive than Pi. If not for these factors, I'd go with Arduino in a heart beat, for it's rich documentation and wide community support.

STM32 family - the most open-source friendly ARM chips out there. Rust has a Zinc project of running on bare metal, that was developed for this chip. Prices start as low as 8$, and there are extension boards available.

Tiva C launchpad kit from Texas Instruments - the most impressive ARMs in terms of website navigation and availability of standard extensions. Bare boards start at 13$ and seem very solid, thus being my current choice.

Freescale Freedom Boards - the most diverse family of ARM chips. I found it difficult to navigate their website and to figure out what exactly I need there. Can't see any extension boards in particular, but I'm sure there are some. Prices start at about 16$, though these boards include some LEDs and switches for demonstration purposes by default.

 

Conclusion

As a starting point, I decided to order one of the low-end ARM chips, and try to get anything programmed to it in Rust. That will take me a while... I may end up contributing some code into Zinc, or even shifting to robotics after-wise, because that's where MCUs really shine. At the same time, I'm going to buy a Nest thermostat with a couple of Nest CO detectors for my family to enjoy while I'm tinkering with low-level stuff. If I ever reach the point where I could control my HVAC and other things remotely by my own program, I'll be happy to replace Nest with something dummier, or just hack it to get the root access to HW.

If thought about home automation, have some solutions installed, or are building your own hub in the garage - please share, as I'll be happy to learn from your experience. If you didn't care about IoT and my article made you interested - you are welcome ;)

Friday, August 15, 2014

Vision

Vision. I often heard this term, read about it, though I knew what this is. I thought, when there is a person in charge, who is a highly skilled engineer, he can see what others can not just because of his engineering capabilities and the fact he goes thinking deeply about the problems (not only existing ones, he is also in a constant search for the new ones). Apparently, it's not that simple.

It turned out, vision is not a consequence of engineering skills but something very different. It's an extraordinary ability to see the future, a hypothetical future of a product evolution. By seeing this, a revisionary can drive product development in leaps, thus making it a revolutionary progression.

It is important to realize this is not "just" about development time (or, the availability of shortcuts). Evaluation is all around us. We evaluate everything we are doing in order to learn from it and adapt. Others evaluate our work in order to figure out if they want to invest in it. Thus, being able to leap forward gives you an instant advantage in terms of evaluation outcome, which transforms the benefit of having a vision from quantity (of time) to quality.

I faced the vision problem when tried to design a large system, in collaboration within a team. I realized (for the first time) that it's not the engineering skills that we lack, but rather a clear vision over where we are going. It doesn't even matter if you are an architect, lead developer, or the god himself. If you got the vision, you'll be heard.

Aside from being mysterious, vision is still a human skill. I wonder if it can be trained, like any other human skill we have. What kind of activity would that be? I don't believe that by just thinking and brainstorming we get any better in visioning in general, we merely dig harder at a specific problem instead. There must be something more generic. Perhaps, playing the music?..

Sunday, December 8, 2013

3C Rules of Personal Development

Create
You know, do stuff. Experiment, hack, write programs, build houses. Creating means going against nature in some way: second law of thermodynamics rules out everything to go into chaos, while creation is about organizing matter or information. Creation is easy and natural behavior of children with their rich imagination, but keeping up with it when you get older requires dedication.

Collaborate
Working on something in isolation can be reasonable, but the potential of collaboration is greater. Discuss your ideas with friends, relatives, and even with random people on the Internet. Visit conferences to hear other peoples ideas, form work groups, and adjust your own goals. A well done argument may multiply each individual intellegence with regards to solving the target problem, when the idea is being ping-ponged between brains, evolving with each hit.

Complete
Creation process is an engine, and to keep working it needs to complete cycles. Finishing stuff gives you fuel to move to the next idea, and allows to draw right conclusions by analyzing the full cycle. Publish your work on the web, give other people a functioning product, not just a bunch of scrap and a github repo link. Receive recognition, push your goal bar higher, and move on.

Sunday, August 18, 2013

Quest for the best scene format

A graphics engine needs to know how to compose a scene from a given set of resources, such as: meshes, skeletons, and textures. This is what scene file is for - it's a document that describes relationship between basic resources, joining them into a system that can be effectively processed by the code. This file is composed either by hand (if the scene is small), or by the exporter script from a 3D modelling program. During the evolution of KRI engine the scene format changed several times. I'll try to review the development history and analyze various formats I used, based on the personal experience.

0. Composed in code: kri-1, kri-2

This is where we all start: just slapping entities on the screen directly.
Lang:    C++
Pros:
    -no export stage
    -no need to validate
    -no parsing
Cons:
    -non extensible

1. Custom binary: kri-3

All scene data and resources were stored in a single binary file of a custom format.
Lang:    Boo
Pros:
    -no external libs
    -fast parsing
Cons:
    -non human-readable -> difficult to debug
    -difficult to validate
    -resources are not separate

2. XML: kri-web

XML is a well-known document format, it has the greatest language/tool support. Besides, that's what we used at my former employer company.
Lang:    Dart, XML
Pros:
    -built-in validation with Schema
    -support for default values
Cons:
    -need to keep Schema synchronized with exporter/loader
    -too verbose
    -bloated loading code (no 1:1 data representation)
    -not clear what to put into attributes -> design ambiguity

3. JSON: claymore-engine

This is where I discovered JSON, and it immediately appealed to me because of the simple syntax and its 1:1 reflection with the data. Fortunately, this is the only format Rust had a built-in support for. However, it turned out to be a poor choice for the scene description due to the lack of heterogeneous structures.
Lang:    Rust, JSON
Pros:
Cons:
    -no heterogeneous structures -> difficult to read

From there I started looking for something like JSON but to describe the document instead of the data. I looked into YAML, which seemed nice, a bit more complex, and not supported by Rust. Then I found Candle Object Notation, which seemed like a non-ambiguous and compact version of XML, plus the 1:1 mapping to data. However, the format is not that well documented and supported... "It would be nice to have the same object initialization syntax as Rust" - I thought when this idea hit me like a train: why not use Rust then?

4. Rust: k-engine

Let's just export a rust source file, which will be compiled with the application.
Lang:    Rust
Pros:
    -free validation (your code is the spec)
    -no run-time parsing -> instant loading, no run-time errors
    -no need to learn new syntax
    -compact (no external file needed to run)
Cons:
    -need to compile the scene
    -bound to the language

This approach seems to be the perfect solution for my scene format. The only thing that worries me is that it depends on Rust compile times. Though, we can still parse Rust code at run time, if we want, while still verifying it at compile time. You can see an actual export result here. It is compact, easy to read, and elegant.