Solid
🎯 A comprehensive gradient-free optimization framework written in Python
Install / Use
/learn @100/SolidQuality Score
Category
Education & ResearchSupported Platforms
Tags
README
Solid is a Python framework for gradient-free optimization.
It contains basic versions of many of the most common optimization algorithms that do not require the calculation of gradients, and allows for very rapid development using them.
It's a very versatile library that's great for learning, modifying, and of course, using out-of-the-box.
See the detailed documentation here.
<hr>Current Features:
- Genetic Algorithm
- Evolutionary Algorithm
- Simulated Annealing
- Particle Swarm Optimization
- Tabu Search
- Harmony Search
- Stochastic Hill Climb
Usage:
pip install solidpy- Import the relevant algorithm
- Create a class that inherits from that algorithm, and that implements the necessary abstract methods
- Call its
.run()method, which always returns the best solution and its objective function value
Example:
from random import choice, randint, random
from string import lowercase
from Solid.EvolutionaryAlgorithm import EvolutionaryAlgorithm
class Algorithm(EvolutionaryAlgorithm):
"""
Tries to get a randomly-generated string to match string "clout"
"""
def _initial_population(self):
return list(''.join([choice(lowercase) for _ in range(5)]) for _ in range(50))
def _fitness(self, member):
return float(sum(member[i] == "clout"[i] for i in range(5)))
def _crossover(self, parent1, parent2):
partition = randint(0, len(self.population[0]) - 1)
return parent1[0:partition] + parent2[partition:]
def _mutate(self, member):
if self.mutation_rate >= random():
member = list(member)
member[randint(0,4)] = choice(lowercase)
member = ''.join(member)
return member
def test_algorithm():
algorithm = Algorithm(.5, .7, 500, max_fitness=None)
best_solution, best_objective_value = algorithm.run()
<hr>
Testing
To run tests, look in the tests folder.
Use pytest; it should automatically find the test files.
<hr>Contributing
Feel free to send a pull request if you want to add any features or if you find a bug.
Check the issues tab for some potential things to do.
Related Skills
claude-opus-4-5-migration
83.0kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
336.9kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
mcp-for-beginners
15.6kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
TrendRadar
49.8k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
