Changeset a0523b8 in observatorio for simulacion/ModuloDinamico
- Timestamp:
- Jan 27, 2015, 9:06:14 AM (9 years ago)
- Branches:
- simulacion
- Children:
- 5c51ff9
- Parents:
- c9dd3b4
- Location:
- simulacion/ModuloDinamico
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
simulacion/ModuloDinamico/io_manager.H
re481d13 ra0523b8 642 642 queue.put(start_node); 643 643 644 while (not queue.is_empty()) {645 644 while (not queue.is_empty()) 645 { 646 646 Graph::Node * src = queue.get(); 647 647 648 648 Good * good = src->get_info().get(); 649 650 Product * ptr_product = static_cast<Product *>(good); 649 651 650 652 List<Aleph::pair<Product, long>> requesters; … … 685 687 ); 686 688 687 ip_relationship.set_purchase_price( 688 get_acquisition_price("N", input_id, year) 689 ip_relationship.set_bought_quantity( 690 get_declared_bought_quantity( 691 ptr_product->get_company_rif(), 692 ptr_product->get_company_name(), 693 input_id, 694 year 695 ) 689 696 ); 697 698 ip_relationship.set_purchase_price(ptr_product->get_price()); 690 699 691 700 g.insert_arc(src, tgt, ip_relationship); … … 715 724 real accum_price = 0.0; 716 725 717 real accum_quantity = 0.0;718 719 726 for (Graph::Node_Arc_Iterator nait(node); nait.has_current(); 720 727 nait.next()) … … 741 748 accum_price += ip_rel.get_purchase_price(); 742 749 743 accum_quantity += ip_rel.get_bought_quantity();744 745 750 ++num_buyers; 746 751 } 747 752 748 753 real external_sales = 0.0; 754 755 real avg_price = accum_price / num_buyers; 749 756 750 757 switch (ptr_good->get_type()) … … 772 779 773 780 (static_cast<Input *>(ptr_good)) 774 ->set_price(a ccum_price / num_buyers);781 ->set_price(avg_price); 775 782 776 783 break; … … 778 785 case IMPORTED_PRODUCT: 779 786 (static_cast<Imported_Product *>(ptr_good)) 780 ->set_imports( accum_quantity);787 ->set_imports(internal_sales / avg_price); 781 788 (static_cast<Imported_Product *>(ptr_good)) 782 ->set_sale( accum_quantity);789 ->set_sale(internal_sales); 783 790 (static_cast<Imported_Product *>(ptr_good)) 784 ->set_requested_quantity( accum_quantity);791 ->set_requested_quantity(internal_sales / avg_price); 785 792 (static_cast<Imported_Product *>(ptr_good)) 786 ->set_price(a ccum_price / num_buyers);793 ->set_price(avg_price); 787 794 788 795 } -
simulacion/ModuloDinamico/simulator.C
r23f4971 ra0523b8 68 68 state_0.stock = 0.0; 69 69 state_0.internal_sales = ptr_product->get_internal_sales(); 70 state_0.external_sales = num_output_arcs == 0 ? ptr_product->get_production() 71 : ptr_product->get_external_sales(); 72 state_0.internal_requested_quantity = ptr_product->get_internal_sales(); 73 state_0.external_requested_quantity = state_0.external_sales; 74 70 state_0.external_sales = num_output_arcs == 0 ? 71 ptr_product->get_production() * 72 ptr_product->get_price() : 73 ptr_product->get_external_sales(); 74 state_0.internal_requested_quantity = 75 state_0.internal_sales / ptr_product->get_price(); 76 state_0.external_requested_quantity = 77 state_0.external_sales / ptr_product->get_price(); 75 78 76 79 state_0.num_employees = ptr_product->get_num_employees(); … … 109 112 state_0.income = state_0.production * state_0.price; 110 113 111 real investment = state_0.administrative_staff_cost + 112 state_0.labor_cost + state_0.input_cost; 113 114 state_0.other_cost = std::abs(state_0.income - investment); 115 116 investment += state_0.other_cost; 117 118 state_0.total_cost = investment + state_0.other_cost; 114 real partial_cost = state_0.administrative_staff_cost + 115 state_0.labor_cost + state_0.input_cost; 116 117 state_0.other_cost = std::abs(state_0.income - partial_cost); 118 119 state_0.total_cost = partial_cost + state_0.other_cost; 119 120 120 121 state_0.unitarian_administrative_staff_cost = … … 127 128 state_0.other_unitarian_cost = state_0.other_cost / state_0.production; 128 129 129 state_0.economic_status = state_0.income - investment;130 state_0.economic_status = state_0.income - state_0.total_cost; 130 131 131 132 ptr_product->add_simulation_attributes(state_0); … … 151 152 state_0.internal_sales = ptr_input->get_internal_sales(); 152 153 state_0.external_sales = ptr_input->get_external_sales(); 153 state_0.internal_requested_quantity = ptr_input->get_internal_sales(); 154 state_0.external_requested_quantity = ptr_input->get_external_sales(); 154 state_0.internal_requested_quantity = 155 state_0.internal_sales / ptr_input->get_price(); 156 state_0.external_requested_quantity = 157 state_0.external_sales / ptr_input->get_price(); 155 158 state_0.price = ptr_input->get_price(); 156 159 … … 183 186 void init_network(Graph & network) 184 187 { 188 Exogenous_Variables & exo_var = Exogenous_Variables::get_instance(); 189 190 exo_var.set_average_salary(exo_var.get_average_salary() * NUM_MONTHS); 191 185 192 for (Graph::Node_Iterator it(network); it.has_current(); it.next()) 186 193 { … … 223 230 /* Una red productiva es realmente un digrafo, la red fue modelada con grafo 224 231 para poder efectuar navegación hacia los nodos de atrás. Para esta 225 construcción se asume una convención de que uno nodo que si el nodo s va226 detrás de t, en un digrafo el arco sería s -> t y en el grafo se respeta ese227 ordenteniendo los arcos s -- t.232 construcción se asume una convención de que si el nodo s va detrás de t, 233 en un digrafo el arco sería s -> t y en el grafo se respeta ese orden 234 teniendo los arcos s -- t. 228 235 229 236 Esta función toma el grafo y lo convierte en un digrafo para aplicar sobre 230 este últimoel algoritmo de construcción de rangos topológicos.237 éste el algoritmo de construcción de rangos topológicos. 231 238 232 239 En los nodos del digrafo se almacenan los punteros a los nodos del grafo y … … 234 241 requeridos para hacer los recorridos por el grafo por cada nivel topológico 235 242 desde el más alto hasta el más bajo, pero finalmente el proceso de simulación 236 se efectúa sobre los nodos del grafo porque se requiere navegación hacia237 atrás.243 se efectúa sobre los nodos del grafo (y no los del digrafo) porque se 244 requiere navegación hacia atrás. 238 245 */ 239 246 void graph_to_digraph(Graph & graph, Digraph & digraph) … … 728 735 const size_t & t) 729 736 { 730 Exogenous_Variables & exo_var = Exogenous_Variables::get_instance();731 732 737 const real & new_price = node->get_info()->price_at(t); 733 738 … … 748 753 749 754 // Al precio de venta se le incrementa la tasa de ganancia. 750 sim_attr.purchase_price = new_price * 751 (1.0 + exo_var.rate_of_gain_at(t) / 100.0); 755 sim_attr.purchase_price = new_price; 752 756 } 753 757 } … … 819 823 // Cálculo de costos administrativos 820 824 sim_attr_t.administrative_staff_cost = 821 ptr_product->get_num_administrative_staff() * wage;825 ptr_product->get_num_administrative_staff() * sim_attr_t.integral_wage; 822 826 sim_attr_t.unitarian_administrative_staff_cost = 823 827 sim_attr_t.administrative_staff_cost / sim_attr_t.production; 824 828 825 829 // Cálculo de costos en mano de obra 826 sim_attr_t.labor_cost = sim_attr_t.num_employees * wage;830 sim_attr_t.labor_cost = sim_attr_t.num_employees * sim_attr_t.integral_wage; 827 831 sim_attr_t.unitarian_labor_cost = 828 832 sim_attr_t.labor_cost / sim_attr_t.production; … … 850 854 sim_attr_t.other_cost; 851 855 852 sim_attr_t.price = sim_attr_t.unitarian_administrative_staff_cost +856 sim_attr_t.price = (sim_attr_t.unitarian_administrative_staff_cost + 853 857 sim_attr_t.unitarian_labor_cost + 854 858 sim_attr_t.input_cost_per_unit + 855 sim_attr_t.other_unitarian_cost; 859 sim_attr_t.other_unitarian_cost) * 860 (1.0 + exo_var.rate_of_gain_at(t) / 100.0); 861 862 sim_attr_t.internal_sales *= sim_attr_t.price; 863 864 sim_attr_t.external_sales *= sim_attr_t.price; 856 865 857 866 update_price_in_output_arcs(network, node, t); 858 867 868 sim_attr_t.economic_status = sim_attr_t.income - sim_attr_t.total_cost; 859 869 } 860 870 … … 877 887 sim_attr_t.price = sim_attr_t_1.price * 878 888 (1.0 + exo_var.rate_of_price_change_at(t) / 100.0); 889 890 sim_attr_t.internal_sales *= sim_attr_t.price; 891 892 sim_attr_t.external_sales *= sim_attr_t.price; 879 893 880 894 update_price_in_output_arcs(network, node, t); -
simulacion/ModuloDinamico/simulator.H
r8eb9820 ra0523b8 40 40 # define RANDOM_UNIF(a, b) (gsl_rng_uniform(rng) * ((b) - (a)) + (a)) 41 41 42 # define DAYS_IN_A_YEAR 360 42 # define DAYS_IN_A_MONTH 30 43 44 # define NUM_MONTHS 12 45 46 # define DAYS_IN_A_YEAR (DAYS_IN_A_MONTH * NUM_MONTHS) 43 47 44 48 # define WAGE_PROPORTION 0.4 45 49 46 # define UT_PROPORTION 0. 2550 # define UT_PROPORTION 0.5 47 51 48 52 typedef Graph_Node<Graph::Node *> D_Node;
Note: See TracChangeset
for help on using the changeset viewer.