Scheduling with Scripts

As scenarios grow in size and complexity, scripting becomes benificial or even necessary.

Optimizing Ground Station Location

An iterative approach to STK Scheduler allows for many optimization abilities. Given several satellites and ground stations STK Scheduler, automated via script, can determine the optimal location of the ground stations for maximizing possiable contact duration. The following steps will outline the procedure for deciding the location of a third ground station given two fixed locations. The figure of merit deciding the optimal location will be assessed by the ratio of assigned contact tasks vs. unassigned timeslots.


Python 2.7 is required for this Use Case

File: Script_Analysis.vdf Path: C:\Program Files\AGI\STK 11\STKScheduler\Scenarios\Use Cases

File: Path: C:\Program Files\AGI\STK 11\STKScheduler\Examples\TCP\Python


Line 163 of will automatically ingest the Script_Analysis.txt commands from the program files. If you wish to ingest the commands you construct in these steps, change the current path to your saved commands absolute path. (See step 6)

  1. Open STK Scheduler.
  2. Load the associated STK Scenario.
    1. Navigate to Schedule > STK > Load Scenario....
    2. In the Schedule Properties window, click Change Scenario.
    3. Select the file path to Script_Analysis.vdf.
    4. Click Open then OK and the STK scenario will be associated with your Scheduler file.
  3. Ingest Resources from STK.
    1. Navigate to Resource > Ingest From STK > All.
    2. In the Select Map Objects for Resource Creation window, use Ctrl + click to select all satellite and facility resources.
    3. Click OK.
  4. Edit the ingested Resources.
    1. Adjust satellite attributes.
      1. Navigate to Resource > Edit Resource.
      2. On the left side of the Resource Editor window use Ctrl + click to select all GPS satellite resources.
      3. In the General tab, locate the New Group field and enter "MEO".
      4. Click the Create button next to New Group.
      5. Select the MEO resource group under Available Groups.
      6. Click the right arrow button to add MEO to the Included Groups.
      7. Click Update.
  5. Create Task definitions.
    1. Go to Task > New Task.
    2. In the Task ID: field, enter "F1_Contact".
    3. In the Duration tab, select the radio button next to Variable Duration.
    4. Set the Min Total Duration to 1 minute and the Max Total Duration to unlimited.
    5. Click the check box next to Allow Multiple Segments.
    6. Adjust the Min Segment Duration to 1 minute.
    7. Click the check box next to Allow Resource Change Between Segments and select the Allow Gaps radio button.
    8. Construct "_1ofMEOs' Constraint Group
      1. In the Resources tab, select "MEO" under Available Resource Groups: and click the right arrow button.
      2. Select the radio button next to Resources From Group and change the field to 1 resource from group.
      3. Click Create Group/List and enter "_1ofMEOs".
      4. Click OK and _1ofMEOs will appear under Available Resources.
    9. Create the following Resource Constraints string: <"Facility1" AND "_1ofMEOs">.
    10. Click Create Possibilities, then Update.
    11. Click Create New Task then repeat steps 5 B-G,I for "F2_Contact" and "F3_Contact" with the respective Resource Constraints string: <"Facility2" AND "_1ofMEOs">, <"Facility3" AND "_1ofMEOs">.
    12. Click Close.
  6. Edit script.
    1. Open in the editor of your choice.
    2. Ensure lines 21-23 are correct.
    3. Export Commands
      1. In Scheduler, navigate to File > Export Commands As... and save the commands in the location of your choice.
    4. Change line 163 from: command = "IngestCommands 'C:\Program Files\AGI\STK 11\STKScheduler\Examples\TCP\Python\Script_Analysis.txt'" to: command = "IngestCommands '<your absolute path>'"
    5. Save
  7. Run the python optimization script.
    1. Run in your method of choice.


The script will print the location number, Latitude, Longitude, and figure of merit (Assigned vs. Unassigned ratio) for the optimal ground station location. It may be beneficial to view the final Schedule and STK Scenario as well.

Ingest Command File

A sample ingest command file named Script_Analysis.txt is available in the Examples/Use Cases folder. Ingesting that file will replicate the schedule described here.