{"id":22614375,"url":"https://github.com/cwahn/system-solver","last_synced_at":"2025-03-29T00:25:43.528Z","repository":{"id":200309734,"uuid":"705237275","full_name":"cwahn/system-solver","owner":"cwahn","description":"Python system of equation solving \u0026 optimization library","archived":false,"fork":false,"pushed_at":"2023-10-19T16:08:29.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-03T10:33:40.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwahn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-15T13:00:55.000Z","updated_at":"2023-11-04T15:08:40.000Z","dependencies_parsed_at":"2025-02-03T10:40:50.686Z","dependency_job_id":null,"html_url":"https://github.com/cwahn/system-solver","commit_stats":null,"previous_names":["cwahn/system-engineering"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fsystem-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fsystem-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fsystem-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fsystem-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwahn","download_url":"https://codeload.github.com/cwahn/system-solver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246119367,"owners_count":20726365,"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":[],"created_at":"2024-12-08T18:09:33.950Z","updated_at":"2025-03-29T00:25:43.504Z","avatar_url":"https://github.com/cwahn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# system-solver\nPython system of equation solving \u0026 optimization library\n\n## Usage\n\n### System Variables\nThe variables of a system should be expressed as a `dataclass` inheriting from `System`. Each member of this class should be of type `Q` which represents a physical quantity with a unit and optional bounds. The initial value of each member will be used as an initial guess to solve the system numerically.\n\n### Equations, Restrictions, and Objective Function\nIn system engineering problems, there often exist complex relations between variables which include equations, restrictions, and objective functions to be minimized.\n\nThe `solve` method of the `System` class will use all equations and restrictions defined within the system class, and it will attempt to minimize the provided objective function.\n\n#### Equation\nEquations represent concrete relations between variables. They should be defined as methods within the system class and decorated with the `@equation` decorator. These methods should return two values, representing the left and right hand sides of the equation.\n\n#### Constraint or Inequality\nThere might be conditions or inequalities that a set of variables should meet. These can be represented as methods within the system class and decorated with the `@less_than` or `@greater_than` decorators.\n\n#### Objective Function\nThe objective function is a callable with the signature `Callable[[System], Union[float, Quantity]]` that the `solve` method attempts to minimize. This function takes the system variables and returns a single value. Only one objective function can be provided for minimization.\n\n## Example\n\n```python\nfrom dataclasses import dataclass\nfrom system_solver.core import Q, System, equation\n\n\n# State all the system variables with initial values and optioanl bounds of variables\n# Q(value: Num, units=None, min: Num = None, max: Num = None, const: bool = False)\n@dataclass\nclass DroneSystem(System):\n    payload: Q = Q(1, \"kg\", const=True)\n    frame_mass: Q = Q(1, \"kg\", 0.5)\n    pizza_box_mass: Q = Q(0.5, \"kg\", 0.3)\n    mtow: Q = Q(4, \"kg\")\n    cruising_speed: Q = Q(7, \"m/s\", 5, 15)\n    endurance: Q = Q(15, \"min\", 10, 25)\n    range: Q = Q(12, \"km\", 10)\n\n    # Equations and inequalities should return lhs, rhs\n    @equation\n    def speed_eq(self):\n        return self.cruising_speed, self.range / self.endurance\n\n    @equation\n    def mass_eq(self):\n        return self.mtow, self.payload + self.frame_mass + self.pizza_box_mass\n\n\n# Optional objective function to minimize\nsolved_system, _ = DroneSystem().solve(lambda x: x.mtow / x.range.magnitude)\n\nprint(solved_system)\n```\n### Result\n\n```\npayload: 1.000 kg\nframe_mass: 0.500 kg\npizza_box_mass: 0.300 kg\nmtow: 1.800 kg\ncruising_speed: 15.000 m/s\nendurance: 25.000 min\nrange: 22.500 km \n```\n\n## Requirements\n```\nPython\u003e=3.10\nnumpy\nPint==0.22\nscipy==1.11.3\ntyping_extensions==4.8.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwahn%2Fsystem-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwahn%2Fsystem-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwahn%2Fsystem-solver/lists"}