_ # Simple Robinson Model This model consists of a single person. He lives alone in the wilderness. He has to build his own tools and catch his own meal. There is no money. There is no trade. There is no cooperation. How can we model the economy of a single person? This might look simple but it is not. Even if we have a single person economy, we will need to model the interaction of the environment with Robinson. The most difficult part is to model how his new inventions affect the work he has to spend producing goods. We also need to model Robinson himself. That is a very difficult task as well. We need to model the choices that robisnson makes with regard to the labor he puts and the products he creates. Does he save goods for the winter? Does he make tools? The problem here is that there is no theory we can use to simulate the human person's choices nor his change of habits due to external factors. Instead of providing an accurate model, we will use a very simple model of the person. As a result, we need to check if the results are affected by that simplification. A very good way of finding that is to allow anyone to replace that simple mode with a more accurate one and see if there are any differences. That will require our abstract api to talk about the external behavior of the person and not his internal motivation. ## Abstract model of a person A person * produces usefull things together with other people and with the use of tools. * invents new tools that help him in production. * consumes the products of his or others' labor. * stores products for future use. * changes his internal state and thus his future behaviour. ```javascript Abstract_Person.prototype.wants_to_produce = function() { throw new Error("Abstract method!"); //index is the index of the product he wants to produce in the products array. var id = -1; return id; } Abstract_Person.prototype.wants_to_invent = function() { throw new Error("Abstract method!"); //index is the index of the technology that he wants to research in the new knowledge array. var id = -1; return id; } Abstract_Person.prototype.wants_to_consume = function() { throw new Error("Abstract method!"); //The indexes of the consumer products that he wants ro consume. var ids = [-1]; return ids; } Abstract_Person.prototype.wants_to_store = function() { throw new Error("Abstract method!"); //The indexes of the consumer products that he wants to store. var ids = [-1]; return ids; } Abstract_Person.prototype.change_internal_state = function() { throw new Error("Abstract method!"); //Used per iteration to change the behavior of a person in the future. } function Abstract_Person() { if (this.constructor === Abstract_Person) { throw new Error("Can't instantiate abstract class!"); } } ``` ## A simple model for the human economic agent. Our main assumption for the modeling of the person is that he has specific wants that determine the choices he makes. We will assume that a person has wants that are common among all people like food, clothing etc. and whose value do not change very much. He will also have wants that are specific to each person and whose value can change a lot or not depending on the person. Of course, we have to take the assumption that the wants do not change based on previous experiences. In other words, the fact that you didn't eat food yesterday doesn't make you hungrier today. Whether that invalidates our results is an interesting question to find. Similarly, we will assume that the person cannot predict what he will want in the future. He can only project his wants of today into the future. Thus that person will not understand that when he gets very old, he would need to have someone to take care of him. Of course, in Robinson's case, that is not possible. Nor will we simulate the physiology and the needs of a human body as it ages. The person will simply die after a randomly generated age. These wants take a value from zero to 1. We assume that the person is thus able to precisely determine how much he wants something and order those wants in the process. Keep in mind that the wants are orthogonal with each other. Any satisfaction of one want doesn't affect other wants. Given that consumer products can satisfy multiple wants, the choices of the person are determined with the addition of all the wants that will be fulfilled with a specific product. Please note that one product alone might not be able to fulfill a specific want by itself. At the same time, one want is either fulfilled or not. The person has to find all the necessary products so that his fulfilment is at least 100%. This is done for simplicity's sake. * if \\[W_{a} < W_{b}\\] then R chooses b. * if \\[W_{a_{1}} + W_{a_{2}} > W_{b}\\] then R chooses a. As we have pointed, the distribution of wants that people are not homogenous. On the contrary, most people desire the fulfillment of basic needs and that desire is unelastic to change. At the same time, people can have a wide diversity in preferences on other needs and their preferences can change a lot as tim e passes by. We will use the gaussian distribution to simulate this, but anyone can provide a more realistic agreggate consumer preferences distribution. #### The gauss distribution $$ G : R \rightarrow R $$ $$G(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{\frac{-(x-\mu)^{2}}{2\sigma^{2}}}$$ ```javascript function Gaussian(sigma_, median_) { Distribution.apply(this); this.sigma = sigma_; this.median = median_; this.const = 1/(sigma * Math.sqrt(2 * Mapth.PI)); this.exp_const = -1/(2 * sigma * sigma); } Gaussian.prototype = Object.create(Distribution.prototype); Gaussian.prototype.constructor = Gaussian; Gaussian.prototype.at = function(x) { return this.const * Math.exp(this.exp_const * (x - this.median) * (x - this.median)); } Gaussian.prototype.max = function() { this.at(this.median); } ``` Going back to defining a simple model for the human economic agent, we will not generate each person with the same wants. We will randomly generate wants but the median will follow the Gaussian distribution. Since the number of wants can be unlimited, it makes sense to have each person understand that it wants something after he finds something that fulfills this want. ```javascript Person.prototype.new_want = function(id, gaussian, magnitude) { var initial_varrriance = magnitude * (2 * Math.random() - 1) * (gaussian.max - (gaussian.at(id))/gaussian.max); this.wants[id] = Math.max(0, gaussian.at(id) + initial_varriance); } ``` The change of preferences will be simulated by this function. The magnitude constant gives us the choice to determine the global magnitude of change of preferences. Here we assume that change in wants is smaller at the median of the gauss distribution. In other words, the necessary wants of most of the people will be much harder to change. ```javascript Person.prototype.change_wants = function(gaussian, magnitude) { Object.keys(this.wants).forEach(function(id){ this.wants[id] = Math.max(0,this.wants[id] + magnitude * (2 * Math.random() - 1) * (gaussian.max - (gaussian.at(id))/gaussian.max)); }); } ``` At the same time that a person has specific wants, he also has a preference in types of work. We generate this the same way we generated the wants but this time we do not have a gaussian distribution, only a uniform distribution. (A task can be either production or research.) ```javascript Person.prototype.new_task_preference = function(id) { this.task_preferences[id] = Math.random(); } ``` ```javascript Person.prototype.change_task_preferences = function(magnitude) { Object.keys(this.task_preferences).forEach(function(id){ this.task_preferences[id] = Math.max(0,this.task_preferences[id] + magnitude * (2 * Math.random() - 1)); }); } ``` We wouldn't have wants if there weren't products that fulfilled those wants. If there weren't, then we would simulate futility rather than the economy. A product thus fulfills specific wants. We specify the percentage of fulfillment that a product provides to a specific want. 1 or 100% means that it has been completely fulfilled. //TODO move these constants at the end of this article and have the user input them for the simulation. ```javascript var total_wants = 100000; var max_product_fulfilled_wants = 10; var wants_gauss_median = 50000; Consumer_product.prototype.new_random_fulfilled_want = function(max_wants, magnitude){ while(true) { var id = Math.random() * max_wants; if (!(id in this.fulfilled_wants)){ this.fulfilled_wants[id] = magnitude * Math.random() * 100; break; } } } function Consumer_product() { this.id; this.fulfilled_wants = {}; this.production_cost; //list of the same product in all its steps of improvement. this.forward_id = -1; this.backward_id = -1; } ``` A product certainly doesn't exist unless you pick it or create it. Thus we need to model the production process. ## Abstract model of a Production process There is one fundamental property of production. Humans create tools to help them in the production process. We will discuss the research process in the next section but we need to use that property so as to model the production process. Thus first of all, production exists that doesn't create human goods but tools. Secondly production itself has as inputs both tools and human labor/materials. Materials can be either raw ones extracted from nature or parts produced in other production plants. Thus another property is that the production process can be split into multiple ones in which the last one assemples the final product. The production process can be defined as a function that takes the above as input and generate a specific product at a specific volume. \\[Process:Tools \times Labor \times Materials \rightarrow Product \\] The abstact process interface that all production processes need to follow, follows. ```javscript Abstract_Process.prototype.produce = function(tools,people) { throw new Error("Abstract method!"); //Returns the volume of production. In case of research returns either a zero indicating the failure of research or the success of research. var volume = 0; return volume; } Abstract_Process.prototype.output = function() { throw new Error("Abstract method!"); //return the type of output that this process produces. //Type has three options: 'knowledge', 'tool' , 'tool_part' , 'consumer_product', 'consumer_product_part' var output = { "type":"knowledge","id":-1 }; returns output; } function Abstract_Process() { if (this.constructor === Abstract_Process) { throw new Error("Can't instantiate abstract class!"); } } ``` ## A concrete production process The main problem for defining a general production process is that the sum of its parts does not determine the whole production process. The way that the process is performed cannot be deduced by the people that take part or the tools. We could add the organization structure as a factor of productivity. Since we cannot meaususe or specify in a general manner the interelations of the workers and their effect on productivity we will have to do the above simplicication. //TODO Haven't done this yet. In order to account for that simplification, we will introduce a productivity multiplication factor that will be generated with a gaussian distribution of small varriance for every group of workers on a specific production process. Having introduced the above multiplier we can now model the production process as the weighted sum of the productivity of the working force mutiplied by the tool that is used. A tool can be used for either production or for research purposes. If a tool is used for research purposes then when the research succeeds, the same tool can be used for manufacturing purposes but it will have a low productivity multiplier. The tool identifies uniquely the production/research process that is using it. If a tool is upgraded, then the only thing that will change is the multiplier. ```javascript function Tool() { this.id; this.multiplier; this.process; this.discovered_by; this.production_cost; this.forward_id = -1; this.backward_id = -1; } ``` Each person also needs to define its productivity with regard to a specific production process. Here again we use a uniform distribution. In general when a person learns of a new task/production_process, it imediatelly knows both its preference to it as well as his productivity, thus our introduction of a helper function. ```javascript Person.prototype.new_task_productivity = function(task_id, process_array) { var process = process_array[task_id]; var number_of_positions = process.position_weights.length(); var multi = []; for( var i = 0; i < number_of_positions; i++) { multi.push(Math.random()); } this.new_task_productivities[task_id] = multi; } Person.prototype.new_task = function(task_id,process_array) { this.new_task_preference(task_id); this.new_task_productivity(task_id, process_array); } ``` \\TODO We have used a uniform distribution. In the next chapter, we will introduce a function that determines the similarity of different knowledge units. This could allow us to determine productivity based on the productivy on similar tasks. Now we are ready to define the production/Research process. We define the output out of a single day of production. ```javascript Process.prototype.output(workers,tool) { var result = 0; var self = this; self.position_weights.forEach(function(weight,index) { for(var i = 0; i < self.number_of_workers_in_position[index]; i++) { result += weight * workers[index][i].task_productivities[self.id][index]; } }); return tool.multiplier * result; } function Process() { this.id; this.position_weights = []; this.number_of_workers_in_position = []; this.weights_sum; this.type; //type can be product consumer_product_part, consumer_product, tool_part, tool, knowledge. this.product_id; //Every tool starts as a research tool for another technology. When that other technology is found, the tool becomes a production tool for the product of that technology. this.required_knowledge = -1; } ``` The difference of a production process and a research process is that the research process most of the times fails to produce the product. The probability of failure will be discussed in the following section. ## Research Research and knowledge is one of the fundamental property of human society. It distinguishes us from other animals. We have the ability to learn new methods and build new tools that helps us in the production of goods necessary for our survival. Thus there can be no model of an economy without incorporating the process of research in it. During reseach, we use research tools and we try to produce new products. Most of the times, our efforts fail and we start again till we succeed. Moreover, even though we aim for a specific product, we do not completey know the outcome. Some times the product is very different than the one we envisioned. In order to determine the probability of a research succeeding, we need to abstract the process of research. We will not know the content of the research. But the content of the research plays an important role in the economy. Let us have an example. A bakery has a bread recipe. If it researchs new knowledge based on the bread recipe, it should be almost impossible to find a way to manufacture bicycles. Why do we have to avoid this in our abstract model? Because then we loose one important characteristic of knowledge/research that influences the economy. Economic agents that have relevant knowledge are much more likely to learn new related knowledge. Thus we need to abstractly identify the relative similarity of different knowledges. By quanitifying the similarity of knowledge we can then provide a formula that describes the similarity of products produced by those researches. The second property of research is that the more knowledge one receives on a certain topic, the more difficult it is to learn new things. This will allow us to provide a formula that determines the probability that a new research will succeed or not. //Todo should I remove that? At the same time, it is not only the previous knowledge the only factor that determine research. Research tools are also required. Tools are randomly generated but the probability of creating a new tool is relatively very low compared to improving an existing tool. In other words, tool creation for research is determined by the same rules like any other product. Let us put those ideas into a more formal language. * A unit of knowledge \\(K\\) depends on a previous knowledge unit \\(K_{d}\\). We say that \\(K\\) depends on \\(K_{d}\\) for its research and we write \\[K_{d} \xrightarrow{dep} K \\]. * We say that \\(K_{a}\\) is an ancestor of \\(K\\) if there is a directed path from \\(K_{a}\\) to \\(K\\) in the graph of Knowledge dependencies. Research is performed in 3 ways. 1. It is performed either for the improvement of a specific knowledge unit. * We say that the new knowledge is an improvement of the previous knowledge and we write \\[K_{i} \xrightarrow{impr} K \\]. 2. It is performed either for the improvement of a specific knowledge unit. * We say that the new knowledge is a specialization of the previous knowledge and we write \\[K_{c} \xrightarrow{spec} K \\]. 3. It is performed on a new Knowledge field and thus it doesnt have any ancestors. Of course, that new knowledege might require tools so as to be researched. Those tools require previous knowledge to be known so as to be built. 4. It is performed so as to generalize a set of knowledges. The new knowledge then becomes the ancestor of those knowledges. ### Results of research The results of research depend on the type of research performed. * Improvement: * The new products and tools that are made possible contain the same characteristics that the previous knowledge allowed, only improved. * The cost of production might increase. * research tools: * If they remained the same, then the production process of those products remains the same. Their cost of production though might increase. * If some of them change, then the new tools used will also take part in the production of the relevant parts of the product. * Specialization or new field Of Knowledge: * The new products and tools have new characteristics that are picked randomly. * As always, the tools of research are used to produce them. * Generalization of a set of Knowledges: * The products and tools of this research are used to improve the products or the knowledge itself contained in the set. Please note that because of the randomness of the characteristics of the tools due to specialization of knowledge, new tools could potentially be used to improve a previous more general knowledge. ### Research Success probability based on the graph of dependencies. The next thing we need to do is to provide a correct probability estimate on the success of a specific research. We need to provide an accurate enough simulation of how difficult a specific research is without knowing the contents of the research. There are 2 things that need simulation. 1. Generating new **research paths**. Each new knowledge that is found introduces new questions and thus new research paths to follow. Researches view those research paths and decide whether to follow them or not. Those research paths might require the use of tools from different fields than the ones used before. We need to simulate that intermixing as well. 2. Generating the probability of each research path succeeding. #### Generating the research paths. //TODO Fix the remaining model of research. Each knowledge can always be improved, so that doesn't need to generated. What needs to be generated is the specializations of this knowledge. Let us point that there are 3 varriables in generating the research paths and we have made some assumptions regarding them. * The research paths that build tools that can improve previous knowledge(circular_specializations) are a fixed percentage with regard to the total number of paths, most possibly small. * The number of parts of a product increases as we specialize our knowledge because each specialization has the ability to create a very small number of things. * The number of new research paths decreases as we specialize. (?) In this generation of research paths, we make 2 assumptions. 1. The percentage of ```javascript Knowledge.prototype.new_random_specializations = function(number_of_new_specializations, knowledge_array, percentage_circular_specializations, perencetage_number_of_parts) { } ``` As we have said previously, we need to decrease the probability of new research if the research community has already found knowledge in a specific sector. Thus the probability of improvement upon a specific sector reduces. The Probability distribution that we will use is not derived empirically but it passes our requirements. \\[\frac{1}{n^2}\\] When we improve the knowledge of a specific sector, the direct dependant technologies improve their probabilities. we use the sum to specify the multiplier that will be used in their probability. \\[\sum{\frac{1}{n^2}}\\] On the specialization probability: When we perform specialization two things happen. First we reduce the subject of inquiry to a small field. That decreases the work one needs to do for research. Secondly, it reduces the possible technological outcomes of the research. We cannot know the results of the research but we do know that the possible outcomes are fewer. Thus the probability of finding a usefull product reduces, thus one needs to do more research to find a usefull product. Thus whether specialization improves the research success or not is not possible to determine beforehand. It must be randomized with a median toward remaining equal. The specialization though still inherits the difficulty of the parental technology. On generalization: When we research a certain sector, one can stumble on a specific problem that leads to an improvement to the general theory. The probability diminshes the more general a theory we depend on, i other words the more hops in our ancestor tree we look to. it is time to write the code: ```javascript Consumer_product.prototype.new_improved_consumer_product = function(consumer_products_array, cp_impr_magnitude, cp_change_cost_magnitude) { var impr_product = new Consumer_product(); impr_product.unique_id = this.unique_id; impr_product.id = consumer_products_array[this.unique_id].length; for(f_want in this.fulfilled_wants) { impr_product.fulfilled_wants[f_want] = this.fulfilled_wants[f_want] + cp_impr_magnitude * Math.random(); impr_product.production_cost = Math.max(0.0001,this.production_cost + (cp_change_cost_magnitude* (2 * Math.random() - 1 ))/(this.production_cost) ); } consumer_products_array[this.unique_id].push(impr_product); return impr_product.id; } Tool.prototype.new_improved_tool = function(knowledge_ids,tools_array, t_impr_magnitude, t_change_cost_magnitude) { var impr_tool = new Tool(); impr_tool.unique_id = this.unique_id; impr_tool.id = tools_array[this.unique_id].length; impr_tool.average_multiplier = this.average_multiplier + t_impr_magnitude * Math.random(); impr_tool.production_cost = this.production_cost + (t_change_cost_magnitude * (2 * Math.random() - 1 ))/this.production_cost; impr_tool.process = this.process; impr_tool.discovered_by = knowledge_ids; tools_array[this.unique_id].push(impr_tool); return impr_tool.id; } function Knowledge() { this.id; this.improvement_level = 0; this.forward_id; this.backward_id; this.dependencies={}; //The sets of tools is used to specify the tools that can be used to research or improve this knowledge. Any of those tools would do. //Each set is expressed as the ordered set of ids joined with the '_'. this.sets_of_tools={}; this.new_tools = {}; //For the new products and new tools, the research tools will be used to produce them at first before much better procedures are found. this.new_consumer_products = {}; this.descendants = {}; //Here we also have the probabilities of merges of different sectors into a new field. this.possible_new_descendands = {}; } Research.prototype.new_knowledge(knowledge, type) { switch (type) { case "improvement": this.new_knowledge_improvement(knowledge); break; case "specialization": this.new_knowledge_specialization(knowledge); break; } } Research.prototype.new_knowledge_improvement = function(knowledges_array, t_impr_magnitude, t_change_cost_magnitude, cp_impr_magnitude, cp_change_cost_magnitude, consumer_products_array, tools_array) { var new_knowledge = new Knowledge(); new_knowledge.unique_id = this.unique_id; new_knowledge.id = knowledges_array[this.unique_id].length; for( dep in this.dependencies) { new_knowledge.dependencies[dep] = true; } for( set in this.sets_of_tools) { new_knowledge.sets_of_tools[set] = true; } for( tool_ids in this.new_tools) { var tool = tools_array[tool_ids.unique_id,tool_ids.id]; var impr_tool_id = tool.new_improved_tool({"id":new_knowledge.id,"unique_id":new_knowledge.unique_id},tools_array,t_impr_magnitude, t_change_cost_magnitude); new_knowledge.new_tools[impr_tool_id] = true; } for( product_ids in this.new_consumer_products) { var product = consumer_products_array[product_ids.unique_id][product_ids.id]; var impr_product_id = product.new_improved_consumer_product(consumer_products_array, cp_impr_magnitude,cp_change_cost_magnitude); new_knowledge.new_consumer_products({"id":impr_product_id,"unique_id":product_ids.unique_id}) = true; } new_knowledge.improvement_level = this.improvement_level + 1; for( descendant in this.descendants) { new_knowledge.descendants[descendant] = true; } for( descendant in this.possible_new_descendants) { new_knowledge.possible_new_descendants[descendant] = true; } knowledges_array[this.unique_id].push(new_knowledge); return new_knowledge.id; } Research.prototype.new_knowledge_specialization = function(knowledge) { } Research.prototype.possible_knowledge_generalization = function(knowledge) { } ``` ### Research types and the effect on the new production processes and their products. The relation of the production processes and products that the new knowledge introduces depends on the type of research performed. For impovement of previous knowledge, the products fulfill similar needs as the knowledge they depend on. For specialization or summing of knowledge(s) there is no relation to the fulfilled needs of the new products with those of the ancestor knowledge(s). The production processes though have similarities since they are similar technologies. Thus there is a relation of the productivity of the workers on the new production processes with the olds ones. Thus from an economic point of view, one would specialize on the field of research with the higher porbability or because the working force has good productivity on this production sector. The same applies for summing different knowledges. //Clean or remove this. We have already pointed about it before. (similarity of distinct knowledges, is this true by the way?) It is important to view the creation of a distinct field of knowledge from multiple ones in this context. As an effort to increase the probability of success. There should be though a multiplying factor in this case. Certainly picking random fields of knowledge and trying to mix them should have less probability due to that randomness. Now that we have defined the graph of knowledge dependencies and types of knowledge expansion, we can use the properties of this abstract graph to define the probability of a research succeeding as well as its results. The relevant code follows: ```javascript function Knowledge() { this.id; this.type; //many only when we sum different knowledges. this.knowledge_dependencies = {}; this.tool_dependencies = {}; this.new_production_processes = {}; //the production processes contain the information about which products this technology enables. } Research_process.prototype.output(workers,tools) { var result = 0; var self = this; self.position_weights.forEach(function(weight,index) { for(var i = 0; i < self.number_of_workers_in_position[index]; i++) { result += weight * workers[index][i].task_productivities[self.id][index]; } }); return tool.multiplier * (result/self.weights_sum); } function Research_process() { this.id; this.position_weights = []; this.number_of_workers_in_position = []; this.weights_sum; this.product_type; this.product_id; //Here we need to generate the above values. we need to look at research to do so. } function research_impr(ancestor, dependencies, tools) { } ``` Now that we have defined the graph of knowledge dependencies and types of knowledge expansion, we can use the properties of this abstract graph to define the probability of a research succeeding as well as its results. ------- At the same time, an improvement on previous knowledge can lead to improvements on the dependent knowledges. * Each knowledge has a probability of producing new knowledge that depends on its position in the graph of knowledge dependencies. * There can be no relation between the tools needed and the knowledge dependencies except from the fact that of tools were usefull to research some knowledge they will still be usefull for improved knowledge. Other than that, the knowledge required to build a tool is independent of its research use. But in order to build a new tool out of some random knowledge for a specific research is very very low. This is also true for products. * Creating a dist field is more probable if dependent multiple knowledges have more similarity. Therd are 2 cases. The improvement is on the technology we are researching or on a more fundamental theory that this research depends on. There are 2 cases. Development of a product or of a technology. Research has 2 processes. First, we merge dinstict knowledge sectors to create a product or a new knowledege sector. Secondly, we use the knowledge of previous merges as a research accelerator. We witness 2 important processes in real life. Previous knowledge can accelerate the research of a similar but better product. Research at the same time can lead to unexpected results that create new products that are not related to the previous ones. It is certain that previous knowledge accelerates research in both cases. What would be the dependencies of the new knowledge on the previous knowledge? Are there multiple research paths on the improvement of the same product with the same previous knowledge? We model knowledge this way. Any previous knowledge can lead to new knowledge but the difficulty of getting new knowledge increases as we extract new knowledge. That is consistent with reality. It can explain why patents block other enterprises from researching similar things. Also, as we learn new things, our new knowledge doesn't give us a lower probability to learn new things. New knowledge is more difficult to learn. ``` function Production_process(id) { this.id; } ``` ```javascript function Person { this.wants = {}; } ```