Skip to main content

一个专门面向造纸行业的高性能约束优化求解器

Project description

Paper Solver

QC Lab发布的首款开源求解器项目

Paper Solver是一个专门面向造纸行业的高性能约束优化求解器,提供了强大的信赖域算法来解决各类约束优化问题。

特性

  • 支持多种约束类型:
    • 边界约束 (BoxConstraint)
    • 线性约束 (LinearConstraint)
    • 非线性约束 (NonlinearConstraint)
  • 提供两种主要的优化算法:
    • 等式约束SQP算法
    • 信赖域内点法
  • 适用于大规模优化问题
  • 支持自动微分和数值微分
  • 提供灵活的约束定义方式

安装

pip install paper-solver

快速开始

以下是一个简单的约束优化问题示例:

from paper_solver import minimize_constrained, NonlinearConstraint
import numpy as np

# 定义目标函数
def objective(x):
    return 100 * (x[1] - x[0]**2)**2 + (1 - x[0])**2

# 定义目标函数的梯度
def gradient(x):
    return np.array([
        -400 * x[0] * (x[1] - x[0]**2) - 2 * (1 - x[0]),
        200 * (x[1] - x[0]**2)
    ])

# 定义约束函数
def constraints(x):
    return np.array([
        x[0]**2 + x[1] - 1,  # 第一个约束
        x[0]**2 - x[1] - 1   # 第二个约束
    ])

# 定义约束的雅可比矩阵
def jacobian(x):
    return np.array([
        [2*x[0], 1],
        [2*x[0], -1]
    ])

# 创建非线性约束
constraint = NonlinearConstraint(
    constraints, 
    ('less', 0),
    jac=jacobian
)

# 求解优化问题
result = minimize_constrained(
    objective,
    x0=np.array([0.0, 1.0]),
    grad=gradient,
    constraints=constraint
)

主要组件

  • minimize_constrained: 核心优化函数
  • BoxConstraint: 用于定义边界约束
  • LinearConstraint: 用于定义线性约束
  • NonlinearConstraint: 用于定义非线性约束

约束类型支持

支持多种约束定义方式:

  • 区间约束:lb <= x <= ub
  • 大于等于约束:x >= lb
  • 小于等于约束:x <= ub
  • 等式约束:x == c

参考文献

  • Byrd, Richard H., Mary E. Hribar, and Jorge Nocedal. "An interior point algorithm for large-scale nonlinear programming." SIAM Journal on Optimization 9.4 (1999): 877-900.
  • Lalee, Marucha, Jorge Nocedal, and Todd Plantega. "On the implementation of an algorithm for large-scale equality constrained optimization." SIAM Journal on Optimization 8.3 (1998): 682-706.

许可证

本项目采用 Apache License 2.0 许可证。详细信息请查看 LICENSE 文件。

Copyright 2024 QC Lab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paper_solver-0.1.0.tar.gz (66.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paper_solver-0.1.0-py3-none-any.whl (54.4 kB view details)

Uploaded Python 3

File details

Details for the file paper_solver-0.1.0.tar.gz.

File metadata

  • Download URL: paper_solver-0.1.0.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for paper_solver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f41e1e8ad7aad9b968abc7ab78b412b9d36df8da155485ff7b340edafaa53944
MD5 7d6b16f2b025aaf2d25d9490095a8bad
BLAKE2b-256 2d48e579ba9ec2fdaa2c64175fb4a26f1bc4f20601b7b3855137ff009b312e05

See more details on using hashes here.

File details

Details for the file paper_solver-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: paper_solver-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 54.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for paper_solver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8452e8be519515b17d70749eb8b9c8431a891eab971e67cc94766109744cbbca
MD5 efc2bf9d5da94358902479522a2cb48a
BLAKE2b-256 35de91f89887c04b33581a755f77e6f54a1f5ad95db11045f7766d1807ed7ae0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page