Qaekwy,一个崭新的Python运筹优化库
我们非常重视原创文章,为尊重知识产权并避免潜在的版权问题,我们在此提供文章的摘要供您初步了解。如果您想要查阅更为详尽的内容,访问作者的公众号页面获取完整文章。
Introduction to Qaekwy
Qaekwy is a Python optimization library introduced in 2023, known for its comprehensive documentation and straightforward modeling and solving process. This article provides an overview of the basic usage of this optimization library.
Installation
pip install Qaekwy
Example
The official basic example demonstrates the ease of starting with Qaekwy, enabling users to perform basic modeling operations after reviewing it.
from qaekwy.engine import DirectEngine from qaekwy.model.constraint.relational import RelationalExpression from qaekwy.model.specific import SpecificMaximum from qaekwy.model.variable.integer import IntegerVariable from qaekwy.model.modeller import Modeller from qaekwy.model.searcher import SearcherType # ... (Example code demonstrating how to define a simple optimization problem)
The general approach involves modeling the problem by setting up model variables, objectives, and the search strategy, followed by solving the problem.
Qaekwy Modeling and Solving Framework
Designing the Model
Establish a model framework, such as a linear programming problem in the basic example.
Defining the Problem
Define the problem with constraints and objective functions.
Setting the Solution Method
Choose a solving method, with Qaekwy offering various options. The example uses the Branch and Bound (BAB) method, which is commonly used for finding optimal solutions.
Instantiating the Qaekwy Engine
The freely available instance of the engine can be used for small to medium-sized problems, with the option to switch to more powerful engines if required.
Solving the Problem
Once the model is set up, the problem can be solved, solutions retrieved, and optimal solutions displayed.
Additional Example - The Knapsack Problem
To further illustrate the modeling and solving process, another example is provided: the knapsack problem.
from qaekwy.engine import DirectEngine from qaekwy.model.constraint.relational import RelationalExpression from qaekwy.model.specific import SpecificMaximum from qaekwy.model.variable.branch import BranchIntegerVal from qaekwy.model.variable.integer import IntegerVariable, IntegerExpressionVariable from qaekwy.model.modeller import Modeller from qaekwy.model.searcher import SearcherType import json # ... (Example code demonstrating how to define a knapsack optimization problem)
想要了解更多内容?