The completed example can be run by executing the k3ssfit.hoc file.
1) Run single and make sure the k3.mod file is one of the "Additional mechanisms." Note that by running "single", we have a soma section of size 100 um2. If the k3.mod mechanism is available then not only can we use it but we can infer that our working directory also has the file needed for the next step.
2) Load the session from the "Pre-analysis" exercise. This already has a similar generator and the steady state data. If you don't have it or want to start from scratch, load the hh508.hoc file instead. Print&FileWindowManager/Session/Retrieve and then open either prefit.ses or hh508.hoc. The following takes the tack of modifying the multiple run fitter in prefit.ses. Refer to the "how to" page for the prefit exercise to recall some hints about setting up the multiple run fitter.
3) Insert the khh mechanism into the patch. NEURONMainPanel/DistributedMechanisms/Managers/Inserter. Checkmark the khh box.
4) From the MulRunFitter, double click on the existing generator to display it. If you are not in the "Display" mode, first select Generators/DisplayGenerator. (Note that this is our desired type of "Function Fitness" and already contains the steady state data).
5) In the generator that popped up, Select Fitness/OrFunctionBody to pop up a string editor. Enter the string
v_init=$1 init() return g_khhFor each x value of the data, v_init will be set to that x value, init() is executed, and finally the value of g_khh is the result of the entire expression. The default init() procedure in the standard run library calls the built-in function finitialize(v_init) which in turn calls the INITIAL block of the k3.mod file. That computes the steady state of the state variables c, o1, and o2. Then the default init() procedure calls the built-in function fcurrent() which in turn calls the BREAKPOINT block of the k3.mod file. That assigns the proper value to g_khh.
6) Change the parameters. Instead of A,k1,d1,k2,d2, they should be gbar_khh, k1_khh, d1_khh, k2_khh, d2_khh. In the MulRunFitter select Parameters/ChangeParameter and double click on the existing parameters to pop up a string editor. Or else remove the existing ones and do a sequence of Parameters/AddParameter If you changed them (as opposed to the remove/add sequence) then their values are the same as the old parameters and clicking on the "ErrorValue" of the generator will give the same fit as the analytic steady state function.
7) Make sure the generator fitness will be added to the total error value by using Generators/PopUp"Use"Panel and checkmarking the generator. (That panel can be Close'd after this is done.) Note that there is a "+" in front of the generator name in the generator list so clicking on the "ErrorValue" in the MulRunFitter main panel shows the same error.
8) Pop up a Parameters/ParameterPanel and Parameters/OptimizerPanel. Start with all parameters at 1 and Optimize.