{"id":17808178,"url":"https://github.com/gabetax/pid_controller","last_synced_at":"2025-03-17T15:30:39.538Z","repository":{"id":56888053,"uuid":"112131629","full_name":"gabetax/pid_controller","owner":"gabetax","description":"Ruby implementation of a PID Controller","archived":false,"fork":false,"pushed_at":"2020-06-24T01:33:42.000Z","size":30,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T00:51:22.520Z","etag":null,"topics":["control-theory","pid-controller","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabetax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-27T01:22:30.000Z","updated_at":"2023-09-11T02:38:47.000Z","dependencies_parsed_at":"2022-08-21T00:50:47.706Z","dependency_job_id":null,"html_url":"https://github.com/gabetax/pid_controller","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabetax%2Fpid_controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabetax%2Fpid_controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabetax%2Fpid_controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabetax%2Fpid_controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabetax","download_url":"https://codeload.github.com/gabetax/pid_controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243865513,"owners_count":20360455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["control-theory","pid-controller","ruby"],"created_at":"2024-10-27T15:08:57.973Z","updated_at":"2025-03-17T15:30:39.077Z","avatar_url":"https://github.com/gabetax.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PidController\n\n[![Gem Version](https://badge.fury.io/rb/pid_controller.svg)](https://badge.fury.io/rb/pid_controller)\n[![Build Status](https://travis-ci.org/gabetax/pid_controller.svg?branch=master)](https://travis-ci.org/gabetax/pid_controller)\n\nThis is a Ruby implementation of a [PID Controller](https://en.wikipedia.org/wiki/PID_controller). A PID controller is a feedback system that is configured with a target setpoint, can read measurements of the system to see how close we are to the setpoint, and will omit an output. Every day examples include:\n\n- Cruise control\n- Thermostats\n- Quadcopters (appearently, because they predominate search results)\n- Database load (yay! This is why the purpose I'm actually writing this for).\n\n## Recommended reading\n\n- [PID without a PhD](https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf)\n- [Throttling Utilities in the IBM DB2 Universal Database Server](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.660.9095\u0026rep=rep1\u0026type=pdf)\n\n## Usage\n\nI mentioned databases, so here's an example of how we can prevent a low priority task (e.g. bulk deletion) from contending with customer traffic:\n\n```ruby\nsensor = MySQLSensor.new # Use your imagination\ncontroller = PIDController.new(\n  setpoint: 60.0,\n  kp: 5.0,\n  ki: 1.0,\n  kd: 0.1,\n  output_max: 0.0,\n  integral_max: 0.0\n  )\n\nEvent.where(account_id: account_id).in_batches do |relation|\n  relation.delete_all\n  backoff = -1 * controller \u003c\u003c sensor.cpu_utilization\n  sleep backoff if backoff \u003e 0\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at \u003chttps://github.com/gabetax/pid_controller.\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabetax%2Fpid_controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabetax%2Fpid_controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabetax%2Fpid_controller/lists"}