⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.doc

📁 王小平《遗传算法——理论、应用与软件实现》随书光盘
💻 DOC
字号:
Convention
    The following conventions are used throughout this document.
       'Enter'    means the Enter key or the Return key.
       Type 'key' means press the specified key without 'Enter'.
       Press F?   means press the specified function key without 'Enter'.
       Enter      means type in the specified text and followed by 'Enter'
                  key.
       Select/Use an option:
               use cursor keys to move the highlighted option and press
               'Enter', or type the upper-cased character on the left.
       GAF is not case sensitive, use either upper or lower cased key.


Using The Menu
    The GAF system menu, at the top of the screen, is the primary user interface
    to the system.  System menu provides sub-menu function selection (function
    menus): File, Run, Display, Control, Adapt, Method, Segment, Feedback,
    Eval, and Help.  Use the first character of each selection or use cursor
    keys (right/left arrows) to select the sub-menu.  When a function menu is
    selected a pull down menu appears to provide function selection.  To
    select a function either by the character on the left of that function or
    move the cursor with up/down arrow keys and then "Enter".  When a function
    is selected, further menu selection or data entry menu may be provided by
    that function.  Press ESC in function menu will return to system menu.
    Press ESC under system menu will bring run function menu, except when the
    system menu was ESCaped from any of the running screen (i.e. from adapting
    or simulation).  Please refer GAF.DOC for details.  The following steps
    are typical for function selection under simulation or adapting.
       press "ESC" to escape back to system menu
       select desired function menu (see above)
       select desired function (see above)
       press "ESC" again under system menu to go back

       
Simulation

    This simple example demonstrates the application of the fuzzy logic to
    control a motor based on its angular position feedback.  Lets assume that
    this is a robot arm, and its arm extension limit (in angular position) is
    from 0 degree to 70 degree.  The inputs to the control loop are the
    position, position error, and the speed, the output is the current to the
    motor.  The example also demonstrates that using fuzzy logic to simulate
    the feedback loop, e.g. the position feedback and the angular speed.  The
    file "robotarm.gaf" defines the control loop, and the file "robotarm.fbk"
    defines the feedback loop.

    Run Simulation
       After start the demo, you'll find the system menu is at the top of the
       screen.  Select run menu by typing 'R', then select "simulation mode"
       by either type 'S' or move high lighted cursor to "simulation mode" and
       press 'Enter'.  After simulation mode is selected, GAF displays the
       control segment on the screen and waits for user input.  Please refer to
       GAF.DOC for details of the display windows.  Type 'F' to start the
       simulation. You should see the trend plots of inputs and outputs on the
       right and the rules and firing status on the left of the screen.

    Reset the system
       Press function key F7 to reset the system.  The system reset is defined
       by the INITIALIZATION declaration in all segments of the system. 
       Type 'F' again to run the simulation.

    View the feedback loop
       Now switch to the feedback loop by pressing F3, the screen displays the
       feedback segment.  Press F7 to reset the system, and then type 'F'. 
       Now watch the plot of the inputs and the outputs for the feedback loop.

    Stepping through
       Let's switch back to the control loop by pressing F3 twice, and reset it
       by F7.  Now press 'Enter' to see the demo program goes one step.  The
       program allows you to do one step by 'Enter' or multiple steps by typing
       2 to 9, or 10 steps by typing '0'.  Type '0' and watch the program goes
       through 10 steps and note different rules are fired.  At any time type
       'F' will bring you to the end of the plot frame.

    Continuous mode
       Press 'C' to run the simulation continuously.  You can stop continuous
       mode by pressing 'C' again or ESCape (press ESC) back to system
       menu.  While in continuous mode press F7 to reset the system.

    Change variable value
       Stop continuous mode by pressing 'C'.  Now let's change the simulation
       from raising the arm to lowering the arm.  Press F7 and then ESC to
       escape back to system menu.  Press 'S' to select segment menu.  The
       segment menu allows you to switch segment and change characteristics
       of the segment.  Switch to feedback segment by selecting "segment
       number" under segment menu, and enter '1' for feedback segment. 
       Select segment menu again, and select "set input value".  GAF pops all
       inputs in a menu beneath the segment menu, select "REFERENCE"
       input and enter its new value to 0.  Select segment menu one more time
       to change the input variable "POSITION" value to 70 (from "set input
       value").  Now get back to the simulation by pressing ESC, press F3 to
       switch back to control segment, and start simulation by stepping through
       it.   Note that you can also change the "POSITION" value from the
       control segment (segment 0).

    View the plot
       From system menu type 'D' to select display menu.  The display menu
       allows you to rearrange the display windows.  Let's select "select plot
       only mode" by typing '5', and then escape back to simulation.  GAF
       should redraw the screen with trend plot takes most of the screen.  Run
       simulation by hiting F7 and then 'F'.

    View the combined result
       From Display menu select "select whole display mode".  The right
       portion of the screen splits into two parts, the upper half shows the
       plot, and the lower half displays the combined result for the output.
       The combined result shows the trapezoid result of all fired rules (rules
       generate non-zero output).  Rerun the simulation by pressing F7, and
       then 'F'.  Now, the combined result tells you about the firing results of
       all rules and the defuzzified crisp output (the current of the motor)
       from all fired rules.

    View details about the fuzzy inference
       The above exercise only allows you to view the combined result of the
       output.  GAF also allows you to examine the firing details of the rules. 
       This feature along with the stepping mode is the best way to tuneup or
       debug the control segment.  From the segment menu, select "display rule
       firing", GAF highlights the first rule by using the left column of the
       text window.  Use down arrow key to move to rule 5 and press 'Enter' to
       select it.  Go back to the simulation, you'll find the selected rule's
       fuzzy sets are displayed to the left of the combined result.  Note that
       each fuzzy set has the same color as the text window.  Try previous
       exercises to view the changes of the fuzzy rule firing status.

    Disable rules
       GAF allows user to disable individual rule for testing fuzzy segment. 
       Let's disable rule 10, this will effectively break the control system. 
       Since there is no rule to respond when the POS_ERROR is
       VERY_LARGE, so after system reset (press F7) there will be no output
       from the control segment.  From segment menu select "disable rule",
       GAF highlights the rule ID 0 on the left of the screen.  Press 'End' to
       move the highlight cursor to rule 10, and then type 'Enter'.  Now restart
       the simulation by pressing F7 then 'F'.  You should see the rule 10 is
       marked with 'X' to indicate it's been disabled, and also that there is no
       response to the position of the robot arm.
    
    Enable rules
       There are two options under segment menu allow you to enable rule(s). 
       The "enable all rules" option enables all rules in this segment.  The
       "enable rule" enables the selected rule.  So, type 'A' under segment
       menu to enable rule 10.

    Change sampling rate
       Another important feature in GAF is that you can tune your system by
       trying different sampling rate (or cycle time defined in each segment). 
       From control menu select "sim schedule rate", GAF prompts for new
       rate.  Enter 0.2 (in second) and restart the simulation.

    Increment/decrement sampling rate
       An easy way to change the simulated sampling rate is to use the '+' and
       '-' keys.  Press '+' each time will cause the sample rate to increase
       0.005 second, and press '-' will decrease the sample rate by 0.005
       second.  The amount of increment/decrement (default is 0.005 second)
       can be changed through the control menu's "Increment value" option. 
       Now put the simulation in continuous mode by 'C', reset it by F7 and
       then use '+' and '-' keys to adjust the sample rate to find out what's
       the max stable rate of the control loop.

    Change output gain
       You can change the gain of the output, from segment menu's "set output
       gain" option.  The default gain is 1.0.

    Check individual segment
       This feature allows you to examine one segment at a time.  Let's
       examine the feedback loop's response at a constant motor current.  Press
       F3 to switch to the feedback segment.  From run menu select "check
       segment".  Then from segment menu change the value of input variable
       "CURRENT" to 1.0.  Run the simulation by typing 'F' to see the
       response of constant current input.

    Getting online help
       Press F1 to get online help.

    Display the system limits
       Press F2 to see the system limits.

    View segment information
       Press F4 to see the variable definition, initialization and normal
       functions, and other information for the selected display segment.

    View symbol definition
       Press F5 to see the fuzzy set symbols' definition for this segment.

    View preset definition
       Press F6 to view the preset definition for this segment.

    Set new plot time frame
       The default plot frame period is five seconds (except in sim clock mode),
       this can be changed through display menu's "plot duration" option.

    View local variables
       The default display mode is to display IN, OUT, and INOUT variables,
       the LOCAL variables are not displayed.  Use "display local variable"
       option in display menu to enable/disable LOCAL variables.

    Quit the program
       Press 'Alt-Q' to quit the program under simulation or select "quit"
       option from run menu.

Adapting the Fuzzy Segment

    The genetic adapt mode is an offline adaptation mode.  While fuzzy logic
    mimics the human's imprecise reasoning, the genetic algorithm mimics the
    evolution of the nature.  The genetic algorithm uses randomization
    techniques to reach local optimum without exhausting searching through the
    solution state space.  With randomization, genetic algorithm is also
    capable of escaping from local optimum and hopping into a new and better
    state.  Apply genetic algorithm in fuzzy control eliminates problems
    associated with fuzzy system.  GAF uses genetic algorithm to derive proper
    rules and fuzzy sets from the initial rules.  By changing, adding, deleting
    rules and fuzzy membership sets of the fuzzy system, the genetic algorithm
    automatically adapts and optimizes the fuzzy control system.

    The adapting example is built on top of the simulation example, by adding
    a third evaluation segment.  The file "robotarm.evl" defines the evaluation
    segment.

    Start Adapting
       From system menu, type 'R' to bring up run menu.  Select "adapt
       mode" by pressing 'A'.  GAF starts adapting the control loop and
       displays the control segment along with adapt status on the top of the
       screen.

    Pause every iteration
       Press Alt-P to halt the adapting after each iteration.  Press 'C' to
       continue next iteration.  Press Alt-C to switch to continuous mode.

    Pause every cycle
       Press Alt-P to stop the adapting after each cycle.  Press 'C' to continue
       next cycle.  Press Alt-C to switch to continuous mode.

    Change size of gene pool
       Press 'Esc' while in continuous adapting, GAF brings up the system
       menu.  Select adapt menu by type 'A'.  From adapt menu select 'max
       best items', and enter a new pool size.  This will change the number of
       genes will be saved (and evaluated) by GAF.

    Change minimum score
       Again, from adapt menu, select "minimum score", GAF prompts for
       new minimum value.  Enter 0.5, this tells GAF to accept all evaluation
       results ,which are greater or equal than 0.5.  The default of the
       minimum score is 0.6.

    Change method
       The method menu provides user to control the algorithm of genetic
       adaptation.  Select "adding rule" from method menu, enter 0 for its new
       weight.  With zero weight, GAF will not generate (adding) new rule into
       the control loop.

    Print the result
       Select 'File' menu from the system menu, and type 'A' to generate
       report for all genes in the gene pool.  The result will be saved in the
       adaptlog.rpt file of the current directory.

    Generate statistic report
       Again type 'S' (generate statistic log) from 'File' menu, GAF produces
       a statistic report file with the file name specified by 'statistic to'
       at the bottom of the menu.  The log includes statistics for all methods.
       Based on the statistic you may want to adjust the weight of the methods.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -