/*(Wed Jul 26 14:56:48 2023) From BALCS for analysis A.mdl - C equations for the model */

#define _VDFX
#define VDFX


#include "vensim.h"
typedef struct tag_workspace {COMPREAL temp0 ; COMPREAL temp1 ; COMPREAL temp2 ; 
COMPREAL temp3 ; COMPREAL temp4 ; COMPREAL temp5 ; COMPREAL temp6 ; 
COMPREAL temp7 ; COMPREAL temp8 ; COMPREAL temp9 ; COMPREAL temp10 ; 
COMPREAL temp11 ; COMPREAL temp12 ; COMPREAL temp13 ; COMPREAL temp14 ; 
COMPREAL temp15 ; COMPREAL temp16 ; COMPREAL temp17 ; COMPREAL temp18 ; 
COMPREAL temp19 ; COMPREAL temp20 ; COMPREAL temp21 ; COMPREAL temp22 ; 
COMPREAL temp23 ; COMPREAL temp24 ; COMPREAL temp25 ; COMPREAL temp26 ; 
COMPREAL temp27 ; COMPREAL temp28 ; COMPREAL temp29 ; COMPREAL temp30 ; 
COMPREAL temp31 ; COMPREAL temp32 ; COMPREAL temp33 ; COMPREAL temp34 ; 
COMPREAL temp35 ; COMPREAL temp36 ; COMPREAL temp37 ; COMPREAL temp38 ; 
COMPREAL temp39 ; COMPREAL temp40 ; COMPREAL temp41 ; COMPREAL temp42 ; 
COMPREAL temp43 ; COMPREAL temp44 ; COMPREAL temp45 ; COMPREAL temp46 ; 
COMPREAL temp47 ; COMPREAL temp48 ; COMPREAL temp49 ; COMPREAL temp50 ; 
COMPREAL temp51 ; COMPREAL temp52 ; COMPREAL temp53 ; COMPREAL temp54 ; 
COMPREAL temp55 ; COMPREAL temp56 ; COMPREAL temp57 ; COMPREAL temp58 ; 
COMPREAL temp59 ; COMPREAL temp60 ; COMPREAL temp61 ; COMPREAL temp62 ; 
COMPREAL temp63 ; COMPREAL temp64 ; COMPREAL temp65 ; COMPREAL temp66 ; 
COMPREAL temp67 ; COMPREAL temp68 ; COMPREAL temp69 ; COMPREAL temp70 ; 
COMPREAL temp71 ; COMPREAL temp72 ; COMPREAL temp73 ; COMPREAL temp74 ; 
COMPREAL temp75 ; COMPREAL temp76 ; COMPREAL temp77 ; COMPREAL temp78 ; 
COMPREAL temp79 ; COMPREAL temp80 ; COMPREAL temp81 ; COMPREAL temp82 ; 
COMPREAL temp83 ; COMPREAL temp84 ; COMPREAL temp85 ; COMPREAL temp86 ; 
COMPREAL temp87 ; COMPREAL temp88 ; COMPREAL temp89 ; COMPREAL temp90 ; 
COMPREAL temp91 ; COMPREAL temp92 ; COMPREAL temp93 ; COMPREAL temp94 ; 
COMPREAL temp95 ; COMPREAL temp96 ; COMPREAL temp97 ; COMPREAL temp98 ; 
COMPREAL temp99 ; COMPREAL temp100 ; COMPREAL temp101 ; COMPREAL temp102 ; 
COMPREAL temp103 ; COMPREAL temp104 ; COMPREAL temp105 ; COMPREAL temp106 ; 
COMPREAL temp107 ; COMPREAL temp108 ; COMPREAL temp109 ; COMPREAL temp110 ; 
COMPREAL temp111 ; COMPREAL temp112 ; COMPREAL temp113 ; COMPREAL temp114 ; 
COMPREAL temp115 ; COMPREAL temp116 ; COMPREAL temp117 ; COMPREAL temp118 ; 
COMPREAL temp119 ; COMPREAL temp120 ; COMPREAL temp121 ; COMPREAL temp122 ; 
COMPREAL temp123 ; COMPREAL temp124 ; COMPREAL temp125 ; COMPREAL temp126 ; 
COMPREAL temp127 ; COMPREAL temp128 ; COMPREAL temp129 ; COMPREAL temp130 ; 
COMPREAL temp131 ; 
int sumind0 ; int forind0 ; 
int sumind1 ; int forind1 ; 

int sumind2 ; int forind2 ; 
int sumind3 ; int forind3 ; 
int sumind4 ; 
int forind4 ; 
int sumind5 ; int forind5 ; 
int sumind6 ; int forind6 ; 

int sumind7 ; int forind7 ; 
int simultid ; 
} WORKSPACE;
#define wrk ((WORKSPACE*)(VGV->workspace))

#define temp0 wrk->temp0
#define temp1 wrk->temp1
#define temp2 wrk->temp2
#define temp3 wrk->temp3
#define temp4 wrk->temp4
#define temp5 wrk->temp5
#define temp6 wrk->temp6
#define temp7 wrk->temp7
#define temp8 wrk->temp8
#define temp9 wrk->temp9
#define temp10 wrk->temp10
#define temp11 wrk->temp11
#define temp12 wrk->temp12
#define temp13 wrk->temp13
#define temp14 wrk->temp14
#define temp15 wrk->temp15
#define temp16 wrk->temp16
#define temp17 wrk->temp17
#define temp18 wrk->temp18
#define temp19 wrk->temp19
#define temp20 wrk->temp20
#define temp21 wrk->temp21
#define temp22 wrk->temp22
#define temp23 wrk->temp23
#define temp24 wrk->temp24
#define temp25 wrk->temp25
#define temp26 wrk->temp26
#define temp27 wrk->temp27
#define temp28 wrk->temp28
#define temp29 wrk->temp29
#define temp30 wrk->temp30
#define temp31 wrk->temp31
#define temp32 wrk->temp32
#define temp33 wrk->temp33
#define temp34 wrk->temp34
#define temp35 wrk->temp35
#define temp36 wrk->temp36
#define temp37 wrk->temp37
#define temp38 wrk->temp38
#define temp39 wrk->temp39
#define temp40 wrk->temp40
#define temp41 wrk->temp41
#define temp42 wrk->temp42
#define temp43 wrk->temp43
#define temp44 wrk->temp44
#define temp45 wrk->temp45
#define temp46 wrk->temp46
#define temp47 wrk->temp47
#define temp48 wrk->temp48
#define temp49 wrk->temp49
#define temp50 wrk->temp50
#define temp51 wrk->temp51
#define temp52 wrk->temp52
#define temp53 wrk->temp53
#define temp54 wrk->temp54
#define temp55 wrk->temp55
#define temp56 wrk->temp56
#define temp57 wrk->temp57
#define temp58 wrk->temp58
#define temp59 wrk->temp59
#define temp60 wrk->temp60
#define temp61 wrk->temp61
#define temp62 wrk->temp62
#define temp63 wrk->temp63
#define temp64 wrk->temp64
#define temp65 wrk->temp65
#define temp66 wrk->temp66
#define temp67 wrk->temp67
#define temp68 wrk->temp68
#define temp69 wrk->temp69
#define temp70 wrk->temp70
#define temp71 wrk->temp71
#define temp72 wrk->temp72
#define temp73 wrk->temp73
#define temp74 wrk->temp74
#define temp75 wrk->temp75
#define temp76 wrk->temp76
#define temp77 wrk->temp77
#define temp78 wrk->temp78
#define temp79 wrk->temp79
#define temp80 wrk->temp80
#define temp81 wrk->temp81
#define temp82 wrk->temp82
#define temp83 wrk->temp83
#define temp84 wrk->temp84
#define temp85 wrk->temp85
#define temp86 wrk->temp86
#define temp87 wrk->temp87
#define temp88 wrk->temp88
#define temp89 wrk->temp89
#define temp90 wrk->temp90
#define temp91 wrk->temp91
#define temp92 wrk->temp92
#define temp93 wrk->temp93
#define temp94 wrk->temp94
#define temp95 wrk->temp95
#define temp96 wrk->temp96
#define temp97 wrk->temp97
#define temp98 wrk->temp98
#define temp99 wrk->temp99
#define temp100 wrk->temp100
#define temp101 wrk->temp101
#define temp102 wrk->temp102
#define temp103 wrk->temp103
#define temp104 wrk->temp104
#define temp105 wrk->temp105
#define temp106 wrk->temp106
#define temp107 wrk->temp107
#define temp108 wrk->temp108
#define temp109 wrk->temp109
#define temp110 wrk->temp110
#define temp111 wrk->temp111
#define temp112 wrk->temp112
#define temp113 wrk->temp113
#define temp114 wrk->temp114
#define temp115 wrk->temp115
#define temp116 wrk->temp116
#define temp117 wrk->temp117
#define temp118 wrk->temp118
#define temp119 wrk->temp119
#define temp120 wrk->temp120
#define temp121 wrk->temp121
#define temp122 wrk->temp122
#define temp123 wrk->temp123
#define temp124 wrk->temp124
#define temp125 wrk->temp125
#define temp126 wrk->temp126
#define temp127 wrk->temp127
#define temp128 wrk->temp128
#define temp129 wrk->temp129
#define temp130 wrk->temp130
#define temp131 wrk->temp131
#define sumind0 wrk->sumind0
#define forind0 wrk->forind0
#define sumind1 wrk->sumind1
#define forind1 wrk->forind1
#define sumind2 wrk->sumind2
#define forind2 wrk->forind2
#define sumind3 wrk->sumind3
#define forind3 wrk->forind3
#define sumind4 wrk->sumind4
#define forind4 wrk->forind4
#define sumind5 wrk->sumind5
#define forind5 wrk->forind5
#define sumind6 wrk->sumind6
#define forind6 wrk->forind6
#define sumind7 wrk->sumind7
#define forind7 wrk->forind7
#define simultid wrk->simultid


#include "simext.c"
static int sub0[]  /* Firm */ = {0,1,-1} ;
#ifndef LINKEXTERN
#endif
unsigned char *mdl_desc()
{
return("(Wed Jul 26 14:56:48 2023) From BALCS for analysis A.mdl") ;
}

/* compute the model rates */
void mdl_func0(GLOB_VARS *VGV)
{double temp[10];
VGV->RATE[0] = 1.0 ;/* this is time */
/* #Effect of Noise on Adoption>PINK NOISE# */
 {
  setpos( 1) ;
  VGV->RATE[1] = VGV->LEVEL[30] ;
} /* #Effect of Noise on Adoption>PINK NOISE# */

/* #Effect of Noise on Attractiveness>PINK NOISE# */
 {
  setpos( 2) ;
  VGV->RATE[2] = VGV->LEVEL[34] ;
} /* #Effect of Noise on Attractiveness>PINK NOISE# */

/* #Reported Demand Dr>PINK NOISE# */
 {
  setpos( 3) ;
  VGV->RATE[3] = VGV->LEVEL[38] ;
} /* #Reported Demand Dr>PINK NOISE# */

/* Adopters M */
 {
  setpos( 4) ;
  VGV->RATE[4] = VGV->LEVEL[41] ;
} /* Adopters M */

/* Authorized Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 5+sub0[forind0]*1) ;
  VGV->RATE[5+sub0[forind0]*1] = (VGV->LEVEL[70+sub0[forind0]*1]-VGV->LEVEL[5
+sub0[forind0]*1])/(VGV->LEVEL[47]/3.000000) ;
} /* Authorized Capacity */

/* Backlog B */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 7+sub0[forind0]*1) ;
  VGV->RATE[7+sub0[forind0]*1] = VGV->LEVEL[139+sub0[forind0]*1]-VGV->LEVEL[165
+sub0[forind0]*1] ;
} /* Backlog B */

/* Capacity K */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 9+sub0[forind0]*1) ;
  VGV->RATE[9+sub0[forind0]*1] = (VGV->LEVEL[19+sub0[forind0]*1]-VGV->LEVEL[9
+sub0[forind0]*1])/(VGV->LEVEL[47]/3.000000) ;
} /* Capacity K */

/* Cumulative Production E */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 11+sub0[forind0]*1) ;
  VGV->RATE[11+sub0[forind0]*1] = VGV->LEVEL[165+sub0[forind0]*1] ;
} /* Cumulative Production E */

/* Expected Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 13+sub0[forind0]*1) ;
  VGV->RATE[13+sub0[forind0]*1] = (VGV->LEVEL[70+sub0[forind0]*1]-
VGV->LEVEL[13+sub0[forind0]*1])/VGV->LEVEL[48] ;
} /* Expected Capacity */

/* Installed Base I */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 16+sub0[forind0]*1) ;
  VGV->RATE[16+sub0[forind0]*1] = VGV->LEVEL[165+sub0[forind0]*1]-
VGV->LEVEL[80+sub0[forind0]*1] ;
} /* Installed Base I */

/* Non Adopters */
 {
  setpos( 18) ;
  VGV->RATE[18] = (-VGV->LEVEL[41]) ;
} /* Non Adopters */

/* Planned Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 19+sub0[forind0]*1) ;
  VGV->RATE[19+sub0[forind0]*1] = (VGV->LEVEL[5+sub0[forind0]*1]-VGV->LEVEL[19
+sub0[forind0]*1])/(VGV->LEVEL[47]/3.000000) ;
} /* Planned Capacity */

/* Price P */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 21+sub0[forind0]*1) ;
  VGV->RATE[21+sub0[forind0]*1] = VGV->LEVEL[147+sub0[forind0]*1] ;
} /* Price P */

/* PV Profit */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 23+sub0[forind0]*1) ;
  VGV->RATE[23+sub0[forind0]*1] = VGV->LEVEL[84+sub0[forind0]*1] ;
} /* PV Profit */

/* Reported Demand Dr */
 {
  setpos( 25) ;
  VGV->RATE[25] = (VGV->LEVEL[112]*EXP(VGV->LEVEL[141]*VGV->LEVEL[3
])-VGV->LEVEL[25])/VGV->LEVEL[68] ;
} /* Reported Demand Dr */

/* Value of Backlog V */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 26+sub0[forind0]*1) ;
  VGV->RATE[26+sub0[forind0]*1] = VGV->LEVEL[179+sub0[forind0]*1]-
VGV->LEVEL[162+sub0[forind0]*1] ;
} /* Value of Backlog V */

} /* comp_rate */

/* compute the delays */
void mdl_func1(GLOB_VARS *VGV)
{double temp[10];
/* Historical Demand */
 {
  setpos( 15) ;
  VGV->RATE[15] = DELAY_INFORMATION_a(0,VGV->LEVEL[25],VGV->LEVEL[110
]) ;
} /* Historical Demand */

} /* comp_delay */

/* initialize time */
void mdl_func2(GLOB_VARS *VGV)
{ double temp[10]; 
if (!VGV->workspace) VGV->workspace = (*VGV->alloc_simmem)(0,0,sizeof(WORKSPACE));
vec_arglist_init(VGV);
VGV->LEVEL[0] = VGV->LEVEL[119] ;
} /* init_time */

/* initialize time step */
void mdl_func3(GLOB_VARS *VGV)
{double temp[10];
/* a constant no need to do anything */
} /* init_tstep */

/* State variable initial value computation*/
void mdl_func4(GLOB_VARS *VGV)
{double temp[10];
/* #Effect of Noise on Adoption>PINK NOISE# */
 {
  setpos( 1) ;
  VGV->LEVEL[1] = (0) ;
}
/* #Effect of Noise on Attractiveness>PINK NOISE# */
 {
  setpos( 2) ;
  VGV->LEVEL[2] = (0) ;
}
/* #Reported Demand Dr>PINK NOISE# */
 {
  setpos( 3) ;
  VGV->LEVEL[3] = (0) ;
}
/* Price P */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 21+sub0[forind0]*1) ;
  VGV->LEVEL[21+sub0[forind0]*1] = 1000.000000 ;
}
/* Minimum Price Pmin */
 {
  setpos( 136) ;
    temp0 = 3.40282e+38 ;
for(sumind0=0;sumind0<2;sumind0++)
 if(temp0 > VGV->LEVEL[21+sub0[sumind0]*1])
   temp0 = VGV->LEVEL[21
+sub0[sumind0]*1] ;
  VGV->LEVEL[136] = temp0 ;
}
/* Relative Price Ratio */
 {
  setpos( 160) ;
  VGV->LEVEL[160] = VGV->LEVEL[136]/VGV->LEVEL[159] ;
}
/* Market Effect of Price */
 {
  setpos( 126) ;
  VGV->LEVEL[126] = POWER(TABLE(&VGV->TAB[3],VGV->LEVEL[160]),VGV->LEVEL[69
]) ;
}
/* Potential Market Mstar */
 {
  setpos( 146) ;
  VGV->LEVEL[146] = VGV->LEVEL[158]*VGV->LEVEL[126] ;
}
/* Adopters M */
 {
  setpos( 4) ;
  VGV->LEVEL[4] = VGV->LEVEL[115]*VGV->LEVEL[146] ;
}
/* Potential Adopters N */
 {
  setpos( 145) ;
  VGV->LEVEL[145] = MAX(0,VGV->LEVEL[146]-VGV->LEVEL[4]) ;
}
/* Installed Base I */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 16+sub0[forind0]*1) ;
  VGV->LEVEL[16+sub0[forind0]*1] = 0.500000*VGV->LEVEL[4]*VGV->LEVEL[177
] ;
}
/* Users */
 {
  setpos( 178) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[16+sub0[sumind0]*1] ;
  VGV->LEVEL[178] = temp0/VGV->LEVEL[177] ;
}
/* Effective Users for WOM */
 {
  setpos( 99) ;
  VGV->LEVEL[99] = VGV->LEVEL[183]*VGV->LEVEL[178]+(1.000000-VGV->LEVEL[183
])*VGV->LEVEL[4] ;
}
/* Effect of Noise on Adoption */
 {
  setpos( 92) ;
  VGV->LEVEL[92] = EXP(VGV->LEVEL[40]*VGV->LEVEL[1]) ;
}
/* Adoption Rate dM */
 {
  setpos( 41) ;
  VGV->LEVEL[41] = VGV->LEVEL[145]*(VGV->LEVEL[51]+VGV->LEVEL[156]
*VGV->LEVEL[99]/VGV->LEVEL[144])*VGV->LEVEL[92] ;
}
/* Initial Order Rate Qi */
 {
  setpos( 118) ;
  VGV->LEVEL[118] = VGV->LEVEL[41]*VGV->LEVEL[177] ;
}
/* Discard Rate D */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 80+sub0[forind0]*1) ;
  VGV->LEVEL[80+sub0[forind0]*1] = VGV->LEVEL[16+sub0[forind0]*1]*
VGV->LEVEL[109] ;
}
/* Replacement Order Rate Qr */
 {
  setpos( 161) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[80+sub0[sumind0]*1] ;
  VGV->LEVEL[161] = temp0 ;
}
/* Industry Order Rate Qo */
 {
  setpos( 112) ;
  VGV->LEVEL[112] = VGV->LEVEL[118]+VGV->LEVEL[161] ;
}
/* Reported Demand Dr */
 {
  setpos( 25) ;
  VGV->LEVEL[25] = VGV->LEVEL[112] ;
}
/* Forecast Horizon lambdaF */
 {
  setpos( 108) ;
  VGV->LEVEL[108] = VGV->LEVEL[47] ;
}
/* Historical Demand */
 {
  setpos( 15) ;
  VGV->LEVEL[15] = DELAY_INFORMATION_i(131,15,0,VGV->LEVEL[25]) ;
}
/* Industry Order Growth Rate ge */
 {
  setpos( 111) ;
  VGV->LEVEL[111] = LN(VGV->LEVEL[25]/VGV->LEVEL[15])/VGV->LEVEL[110
] ;
}
/* Expected Demand De */
 {
  setpos( 102) ;
  VGV->LEVEL[102] = VGV->LEVEL[25]*EXP(VGV->LEVEL[108]*VGV->LEVEL[111
]) ;
}
/* Initial Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 116+sub0[forind0]*1) ;
  VGV->LEVEL[116+sub0[forind0]*1] = 0.500000*VGV->LEVEL[102]/VGV->LEVEL[137
] ;
}
/* Authorized Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 5+sub0[forind0]*1) ;
  VGV->LEVEL[5+sub0[forind0]*1] = VGV->LEVEL[116+sub0[forind0]*1] ;
}
/* Backlog B */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 7+sub0[forind0]*1) ;
  VGV->LEVEL[7+sub0[forind0]*1] = 0.500000*VGV->LEVEL[112]*VGV->LEVEL[138
] ;
}
/* Capacity K */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 9+sub0[forind0]*1) ;
  VGV->LEVEL[9+sub0[forind0]*1] = VGV->LEVEL[116+sub0[forind0]*1] ;
}
/* Cumulative Production E */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 11+sub0[forind0]*1) ;
  VGV->LEVEL[11+sub0[forind0]*1] = VGV->LEVEL[113+sub0[forind0]*1]
 ;
}
/* Expected Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 13+sub0[forind0]*1) ;
  VGV->LEVEL[13+sub0[forind0]*1] = VGV->LEVEL[9+sub0[forind0]*1] ;
}
/* Initial Unit Fixed Cost */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 120+sub0[forind0]*1) ;
  VGV->LEVEL[120+sub0[forind0]*1] = VGV->LEVEL[21+sub0[forind0]*1]
/(1.000000+VGV->LEVEL[157])*VGV->LEVEL[107]/(1.000000+VGV->LEVEL[107
]/VGV->LEVEL[137]) ;
}
/* Initial Unit Variable Cost */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 122+sub0[forind0]*1) ;
  VGV->LEVEL[122+sub0[forind0]*1] = VGV->LEVEL[21+sub0[forind0]*1]
/(1.000000+VGV->LEVEL[157])/(1.000000+VGV->LEVEL[107]/VGV->LEVEL[137
]) ;
}
/* Learning Coefficient gamma */
 {
  setpos( 124) ;
  VGV->LEVEL[124] = LN(VGV->LEVEL[125])/LN(2.000000) ;
}
/* Non Adopters */
 {
  setpos( 18) ;
  VGV->LEVEL[18] = VGV->LEVEL[144]-VGV->LEVEL[4] ;
}
/* Planned Capacity */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 19+sub0[forind0]*1) ;
  VGV->LEVEL[19+sub0[forind0]*1] = VGV->LEVEL[116+sub0[forind0]*1]
 ;
}
/* PV Profit */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 23+sub0[forind0]*1) ;
  VGV->LEVEL[23+sub0[forind0]*1] = 0 ;
}
/* Value of Backlog V */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 26+sub0[forind0]*1) ;
  VGV->LEVEL[26+sub0[forind0]*1] = VGV->LEVEL[7+sub0[forind0]*1]*VGV->LEVEL[21
+sub0[forind0]*1] ;
}
} /* comp_init */

/* State variable re-initial value computation*/
void mdl_func5(GLOB_VARS *VGV)
{double temp[10];
} /* comp_reinit */

/*  Active Time Step Equation */
void mdl_func6(GLOB_VARS *VGV)
{double temp[10];
} /* comp_tstep */
/*  Auxiliary variable equations*/
void mdl_func7(GLOB_VARS *VGV)
{double temp[10];
/* #Effect of Noise on Adoption>PINK NOISE>white noise# */
 {
  setpos( 31) ;
  VGV->LEVEL[31] = RANDOM_NORMAL((-6.000000),6.000000,0,1.000000,VGV->LEVEL[167
]) ;
}
/* #Effect of Noise on Adoption>PINK NOISE>scaled white noise# */
 {
  setpos( 29) ;
  VGV->LEVEL[29] = (0)+VGV->LEVEL[31]*SQRT((1.000000)*(1.000000)*(
2.000000-VGV->LEVEL[168]/VGV->LEVEL[52])/(VGV->LEVEL[168]/VGV->LEVEL[52
])) ;
}
/* #Effect of Noise on Adoption>PINK NOISE>gap# */
 {
  setpos( 28) ;
  VGV->LEVEL[28] = VGV->LEVEL[29]-VGV->LEVEL[1] ;
}
/* #Effect of Noise on Adoption>PINK NOISE>updating pink noise# */
 {
  setpos( 30) ;
  VGV->LEVEL[30] = VGV->LEVEL[28]/VGV->LEVEL[52] ;
}
/* #Effect of Noise on Attractiveness>PINK NOISE>white noise# */
 {
  setpos( 35) ;
  VGV->LEVEL[35] = RANDOM_NORMAL((-6.000000),6.000000,0,1.000000,VGV->LEVEL[167
]) ;
}
/* #Effect of Noise on Attractiveness>PINK NOISE>scaled white noise# */
 {
  setpos( 33) ;
  VGV->LEVEL[33] = (0)+VGV->LEVEL[35]*SQRT((1.000000)*(1.000000)*(
2.000000-VGV->LEVEL[168]/VGV->LEVEL[52])/(VGV->LEVEL[168]/VGV->LEVEL[52
])) ;
}
/* #Effect of Noise on Attractiveness>PINK NOISE>gap# */
 {
  setpos( 32) ;
  VGV->LEVEL[32] = VGV->LEVEL[33]-VGV->LEVEL[2] ;
}
/* #Effect of Noise on Attractiveness>PINK NOISE>updating pink noise# */
 {
  setpos( 34) ;
  VGV->LEVEL[34] = VGV->LEVEL[32]/VGV->LEVEL[52] ;
}
/* #Reported Demand Dr>PINK NOISE>white noise# */
 {
  setpos( 39) ;
  VGV->LEVEL[39] = RANDOM_NORMAL((-6.000000),6.000000,0,1.000000,VGV->LEVEL[167
]) ;
}
/* #Reported Demand Dr>PINK NOISE>scaled white noise# */
 {
  setpos( 37) ;
  VGV->LEVEL[37] = (0)+VGV->LEVEL[39]*SQRT((1.000000)*(1.000000)*(
2.000000-VGV->LEVEL[168]/VGV->LEVEL[52])/(VGV->LEVEL[168]/VGV->LEVEL[52
])) ;
}
/* #Reported Demand Dr>PINK NOISE>gap# */
 {
  setpos( 36) ;
  VGV->LEVEL[36] = VGV->LEVEL[37]-VGV->LEVEL[3] ;
}
/* #Reported Demand Dr>PINK NOISE>updating pink noise# */
 {
  setpos( 38) ;
  VGV->LEVEL[38] = VGV->LEVEL[36]/VGV->LEVEL[52] ;
}
/* Minimum Price Pmin */
 {
  setpos( 136) ;
    temp0 = 3.40282e+38 ;
for(sumind0=0;sumind0<2;sumind0++)
 if(temp0 > VGV->LEVEL[21+sub0[sumind0]*1])
   temp0 = VGV->LEVEL[21
+sub0[sumind0]*1] ;
  VGV->LEVEL[136] = temp0 ;
}
/* Relative Price Ratio */
 {
  setpos( 160) ;
  VGV->LEVEL[160] = VGV->LEVEL[136]/VGV->LEVEL[159] ;
}
/* Market Effect of Price */
 {
  setpos( 126) ;
  VGV->LEVEL[126] = POWER(TABLE(&VGV->TAB[3],VGV->LEVEL[160]),VGV->LEVEL[69
]) ;
}
/* Potential Market Mstar */
 {
  setpos( 146) ;
  VGV->LEVEL[146] = VGV->LEVEL[158]*VGV->LEVEL[126] ;
}
/* Potential Adopters N */
 {
  setpos( 145) ;
  VGV->LEVEL[145] = MAX(0,VGV->LEVEL[146]-VGV->LEVEL[4]) ;
}
/* Users */
 {
  setpos( 178) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[16+sub0[sumind0]*1] ;
  VGV->LEVEL[178] = temp0/VGV->LEVEL[177] ;
}
/* Effective Users for WOM */
 {
  setpos( 99) ;
  VGV->LEVEL[99] = VGV->LEVEL[183]*VGV->LEVEL[178]+(1.000000-VGV->LEVEL[183
])*VGV->LEVEL[4] ;
}
/* Effect of Noise on Adoption */
 {
  setpos( 92) ;
  VGV->LEVEL[92] = EXP(VGV->LEVEL[40]*VGV->LEVEL[1]) ;
}
/* Adoption Rate dM */
 {
  setpos( 41) ;
  VGV->LEVEL[41] = VGV->LEVEL[145]*(VGV->LEVEL[51]+VGV->LEVEL[156]
*VGV->LEVEL[99]/VGV->LEVEL[144])*VGV->LEVEL[92] ;
}
/* Effect of Price on Attractiveness */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 95+sub0[forind0]*1) ;
  VGV->LEVEL[95+sub0[forind0]*1] = EXP(VGV->LEVEL[151]*VGV->LEVEL[21
+sub0[forind0]*1]/VGV->LEVEL[159]) ;
}
/* Desired Shipment Rate Qstar */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 78+sub0[forind0]*1) ;
  VGV->LEVEL[78+sub0[forind0]*1] = VGV->LEVEL[7+sub0[forind0]*1]/VGV->LEVEL[138
] ;
}
/* Shipment Rate Q */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 165+sub0[forind0]*1) ;
  VGV->LEVEL[165+sub0[forind0]*1] = MIN(VGV->LEVEL[78+sub0[forind0]
*1],VGV->LEVEL[9+sub0[forind0]*1]) ;
}
/* Delivery Delay */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 62+sub0[forind0]*1) ;
  VGV->LEVEL[62+sub0[forind0]*1] = VGV->LEVEL[7+sub0[forind0]*1]/VGV->LEVEL[165
+sub0[forind0]*1] ;
}
/* Effect of Delivery Delay on Attractiveness */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 88+sub0[forind0]*1) ;
  VGV->LEVEL[88+sub0[forind0]*1] = EXP(VGV->LEVEL[61]*VGV->LEVEL[62
+sub0[forind0]*1]/VGV->LEVEL[138]) ;
}
/* Effect of Noise on Attractiveness */
 {
  setpos( 93+1*1) ;
  VGV->LEVEL[93+1*1] = EXP(VGV->LEVEL[44]*VGV->LEVEL[2]) ;
}
/* Attractiveness A */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 42+sub0[forind0]*1) ;
  VGV->LEVEL[42+sub0[forind0]*1] = VGV->LEVEL[95+sub0[forind0]*1]*
VGV->LEVEL[88+sub0[forind0]*1]*VGV->LEVEL[93+sub0[forind0]*1] ;
}
/* Average Value of Backlog */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 45+sub0[forind0]*1) ;
  VGV->LEVEL[45+sub0[forind0]*1] = ZIDZ(0,VGV->LEVEL[26+sub0[forind0]
*1],VGV->LEVEL[7+sub0[forind0]*1]) ;
}
/* Capacity Utilization */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 49+sub0[forind0]*1) ;
  VGV->LEVEL[49+sub0[forind0]*1] = ZIDZ(0,VGV->LEVEL[165+sub0[forind0]
*1],VGV->LEVEL[9+sub0[forind0]*1]) ;
}
/* Cost Ratio */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 59+sub0[forind0]*1) ;
  VGV->LEVEL[59+sub0[forind0]*1] = POWER((VGV->LEVEL[11+sub0[forind0]
*1]/VGV->LEVEL[113+sub0[forind0]*1]),VGV->LEVEL[124]) ;
}
/* Unit Variable Cost Uv */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 175+sub0[forind0]*1) ;
  VGV->LEVEL[175+sub0[forind0]*1] = VGV->LEVEL[59+sub0[forind0]*1]
*VGV->LEVEL[122+sub0[forind0]*1] ;
}
/* Unit Fixed Cost Uf */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 173+sub0[forind0]*1) ;
  VGV->LEVEL[173+sub0[forind0]*1] = VGV->LEVEL[120+sub0[forind0]*1
]*VGV->LEVEL[59+sub0[forind0]*1] ;
}
/* Cost Price Pc */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 55+sub0[forind0]*1) ;
  VGV->LEVEL[55+sub0[forind0]*1] = (1.000000+VGV->LEVEL[72+sub0[forind0]
*1])*(VGV->LEVEL[175+sub0[forind0]*1]+VGV->LEVEL[173+sub0[forind0]
*1]/VGV->LEVEL[137]) ;
}
/* Cost Price Ratio */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 57+sub0[forind0]*1) ;
  VGV->LEVEL[57+sub0[forind0]*1] = VGV->LEVEL[55+sub0[forind0]*1]/
VGV->LEVEL[21+sub0[forind0]*1] ;
}
/* Demand Capacity Ratio */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 64+sub0[forind0]*1) ;
  VGV->LEVEL[64+sub0[forind0]*1] = VGV->LEVEL[78+sub0[forind0]*1]/
(VGV->LEVEL[9+sub0[forind0]*1]*VGV->LEVEL[137]) ;
}
/* Industry Order Growth Rate ge */
 {
  setpos( 111) ;
  VGV->LEVEL[111] = LN(VGV->LEVEL[25]/VGV->LEVEL[15])/VGV->LEVEL[110
] ;
}
/* Expected Demand De */
 {
  setpos( 102) ;
  VGV->LEVEL[102] = VGV->LEVEL[25]*EXP(VGV->LEVEL[108]*VGV->LEVEL[111
]) ;
}
/* Expected Competitor Capacity Ke */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 100+sub0[forind0]*1) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[13+sub0[sumind0]*1] ;
  VGV->LEVEL[100+sub0[forind0]*1] = temp0-VGV->LEVEL[13+sub0[forind0]
*1] ;
}
/* Uncontested Demand */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 169+sub0[forind0]*1) ;
  VGV->LEVEL[169+sub0[forind0]*1] = VGV->LEVEL[102]-VGV->LEVEL[137
]*VGV->LEVEL[100+sub0[forind0]*1] ;
}
/* Uncontested Market Share Su */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 171+sub0[forind0]*1) ;
  VGV->LEVEL[171+sub0[forind0]*1] = MAX(0,VGV->LEVEL[169+sub0[forind0]
*1]/VGV->LEVEL[102]) ;
}
/* Desired Market Share Sstar */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 74+sub0[forind0]*1) ;
  VGV->LEVEL[74+sub0[forind0]*1] = MAX(VGV->LEVEL[134+sub0[forind0]
*1],MIN(VGV->LEVEL[131+sub0[forind0]*1],VGV->LEVEL[171+sub0[forind0]
*1])) ;
}
/* Desired Capacity Kstar */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 70+sub0[forind0]*1) ;
  VGV->LEVEL[70+sub0[forind0]*1] = MAX(VGV->LEVEL[133],VGV->LEVEL[74
+sub0[forind0]*1]*VGV->LEVEL[102]/VGV->LEVEL[137]) ;
}
/* Effect of Cost */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 86+sub0[forind0]*1) ;
  VGV->LEVEL[86+sub0[forind0]*1] = POWER(TABLE(&VGV->TAB[0],VGV->LEVEL[57
+sub0[forind0]*1]),VGV->LEVEL[53+sub0[forind0]*1]) ;
}
/* Effect of Demand */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 90+sub0[forind0]*1) ;
  VGV->LEVEL[90+sub0[forind0]*1] = POWER(TABLE(&VGV->TAB[1],VGV->LEVEL[64
+sub0[forind0]*1]),VGV->LEVEL[66+sub0[forind0]*1]) ;
}
/* Market Share S */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 129+sub0[forind0]*1) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[165+sub0[sumind0]*1] ;
  VGV->LEVEL[129+sub0[forind0]*1] = VGV->LEVEL[165+sub0[forind0]*1
]/temp0 ;
}
}
void mdl_func8(GLOB_VARS *VGV) ;
void mdl_func8(GLOB_VARS *VGV){double temp[10];
/* Effect of Share */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 97+sub0[forind0]*1) ;
  VGV->LEVEL[97+sub0[forind0]*1] = POWER(TABLE(&VGV->TAB[2],VGV->LEVEL[74
+sub0[forind0]*1]-VGV->LEVEL[129+sub0[forind0]*1]),VGV->LEVEL[127+sub0[forind0]
*1]) ;
}
/* Desired Price */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 76+sub0[forind0]*1) ;
  VGV->LEVEL[76+sub0[forind0]*1] = MAX(VGV->LEVEL[175+sub0[forind0]
*1],VGV->LEVEL[21+sub0[forind0]*1]*VGV->LEVEL[86+sub0[forind0]*1]*
VGV->LEVEL[90+sub0[forind0]*1]*VGV->LEVEL[97+sub0[forind0]*1]) ;
}
/* Discard Rate D */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 80+sub0[forind0]*1) ;
  VGV->LEVEL[80+sub0[forind0]*1] = VGV->LEVEL[16+sub0[forind0]*1]*
VGV->LEVEL[109] ;
}
/* Discard Rate Prior Log Likelihood */
 {
  setpos( 82) ;
  VGV->LEVEL[82] = (-POWER(((VGV->LEVEL[152]-VGV->LEVEL[109])/VGV->LEVEL[153
]),2.000000)) ;
}
/* Revenue R */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 162+sub0[forind0]*1) ;
  VGV->LEVEL[162+sub0[forind0]*1] = VGV->LEVEL[165+sub0[forind0]*1
]*VGV->LEVEL[45+sub0[forind0]*1] ;
}
/* Fixed Costs Cf */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 105+sub0[forind0]*1) ;
  VGV->LEVEL[105+sub0[forind0]*1] = VGV->LEVEL[9+sub0[forind0]*1]*
VGV->LEVEL[173+sub0[forind0]*1] ;
}
/* Variable Costs Cv */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 181+sub0[forind0]*1) ;
  VGV->LEVEL[181+sub0[forind0]*1] = VGV->LEVEL[165+sub0[forind0]*1
]*VGV->LEVEL[175+sub0[forind0]*1] ;
}
/* Profit */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 154+sub0[forind0]*1) ;
  VGV->LEVEL[154+sub0[forind0]*1] = VGV->LEVEL[162+sub0[forind0]*1
]-VGV->LEVEL[105+sub0[forind0]*1]-VGV->LEVEL[181+sub0[forind0]*1] ;
}
/* Discounted Profit */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 84+sub0[forind0]*1) ;
  VGV->LEVEL[84+sub0[forind0]*1] = VGV->LEVEL[154+sub0[forind0]*1]
*EXP((-VGV->LEVEL[83])*(VGV->LEVEL[0]-VGV->LEVEL[119])) ;
}
/* Initial Order Rate Qi */
 {
  setpos( 118) ;
  VGV->LEVEL[118] = VGV->LEVEL[41]*VGV->LEVEL[177] ;
}
/* Replacement Order Rate Qr */
 {
  setpos( 161) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[80+sub0[sumind0]*1] ;
  VGV->LEVEL[161] = temp0 ;
}
/* Industry Order Rate Qo */
 {
  setpos( 112) ;
  VGV->LEVEL[112] = VGV->LEVEL[118]+VGV->LEVEL[161] ;
}
/* Order Share So */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 142+sub0[forind0]*1) ;
    temp0 = 0.0 ;
for(sumind0=0;sumind0<2;sumind0++)
    temp0 += VGV->LEVEL[42+sub0[sumind0]*1] ;
  VGV->LEVEL[142+sub0[forind0]*1] = VGV->LEVEL[42+sub0[forind0]*1]
/temp0 ;
}
/* Order Rate O */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 139+sub0[forind0]*1) ;
  VGV->LEVEL[139+sub0[forind0]*1] = VGV->LEVEL[142+sub0[forind0]*1
]*VGV->LEVEL[112] ;
}
/* Price Adj Rate dP */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 147+sub0[forind0]*1) ;
  VGV->LEVEL[147+sub0[forind0]*1] = (VGV->LEVEL[76+sub0[forind0]*1
]-VGV->LEVEL[21+sub0[forind0]*1])/VGV->LEVEL[149+sub0[forind0]*1] ;
}
/* Value of Orders */
for(forind0=0;forind0<2;forind0++)
 {
  setpos( 179+sub0[forind0]*1) ;
  VGV->LEVEL[179+sub0[forind0]*1] = VGV->LEVEL[139+sub0[forind0]*1
]*VGV->LEVEL[21+sub0[forind0]*1] ;
}
} /* comp_aux */
int execute_curloop(GLOB_VARS *VGV) {return(0);}
static void vec_arglist_init(GLOB_VARS *VGV)
{
}
void VEFCC comp_rate(GLOB_VARS *VGV)
{
mdl_func0(VGV);
}

void VEFCC comp_delay(GLOB_VARS *VGV)
{
mdl_func1(VGV);
}

void VEFCC init_time(GLOB_VARS *VGV)
{
mdl_func2(VGV);
}

void VEFCC init_tstep(GLOB_VARS *VGV)
{
mdl_func3(VGV);
}

void VEFCC comp_init(GLOB_VARS *VGV)
{
mdl_func4(VGV);
}

void VEFCC comp_reinit(GLOB_VARS *VGV)
{
mdl_func5(VGV);
}

void VEFCC comp_tstep(GLOB_VARS *VGV)
{
mdl_func6(VGV);
}

void VEFCC comp_aux(GLOB_VARS *VGV)
{
mdl_func7(VGV);
mdl_func8(VGV);
}

