file-type

Python库time_space_reductions-1.4安装指南

版权申诉
3KB | 更新于2024-11-09 | 99 浏览量 | 0 下载量 举报 收藏
download 限时特惠:#14.90
Wheel是Python的一种分发格式,旨在加速Python包的安装过程。该文件是一个二进制分发包,适用于Python 3,并且不依赖于特定的操作系统平台(any)。这意味着它可以跨不同系统安装,只要这些系统的Python解释器版本支持该包。Wheel文件可以由像pip这样的包管理工具安装,从而避免了在安装过程中重新编译源代码的需要,从而提高安装速度和效率。 具体到这个文件,time_space_reductions-1.4-py3-none-any.whl是“time_space_reductions”这个Python库的版本1.4。虽然描述中没有提供该库具体实现的功能,但从库的命名来看,可能与时间或空间复杂度的优化、简化有关。在计算机科学中,“时间复杂度”指的是算法执行所需的时间与输入数据量之间的关系,而“空间复杂度”指的是算法所需存储空间与输入数据量之间的关系。通过优化这两者,可以在不改变算法正确性的前提下,提高算法的效率,从而在处理大量数据时,提升程序性能或减少所需计算资源。 在开发Python程序时,合理利用这样的库可以提升程序性能,尤其是在数据密集型或算法密集型的项目中。例如,如果一个库提供了特定算法的优化版本,开发者可以无需从头开始编写复杂的优化代码,而是直接利用现有的库,这样不仅可以节省开发时间,还可以减少错误的可能性。此外,库的维护者会不断地对库进行更新和优化,因此使用标准库或第三方库可以间接地享受到这些改进。 库文件的版本号“1.4”表明它是一个经过了一段时间发展的软件包,经历了多个版本的迭代更新。版本号中,前两位通常表示主要版本号和次要版本号,而1.4表明该版本相对于之前的1.3版本可能是一个小的迭代更新,或者可能包括了一些新的特性和改进,但不涉及重大变更。开发者在选择使用特定版本的库时,需要考虑新版本是否与现有系统兼容,以及新版本是否解决了可能存在的已知问题。 标签中提到的“python 开发语言 Python库”,意味着这是一个专门针对Python语言开发的库。Python是一种广泛使用的高级编程语言,以其简洁的语法和强大的库支持而闻名。Python的库非常丰富,涵盖了从基础编程任务到特定领域应用的方方面面。这些库通过各种预构建的函数和类,极大地减少了编程工作量,提高了开发效率。 总之,time_space_reductions-1.4-py3-none-any.whl文件是一个为Python语言开发的库,专注于优化算法的时间和空间复杂度,提供了一个无需编译且可跨平台安装的Wheel格式包,非常适合需要进行算法优化和性能提升的Python项目。"

相关推荐

filetype

import cvxpy as cp import numpy as np import pandas as pd data = pd.read_excel('附件1.xlsx') X = data.iloc[1:, 1:2] Y = data.iloc[1:, 2:3] W = data.iloc[2:, 3:4] # 收集点垃圾量(i=1..n) xi = X.values.flatten() # 转换为一维数组 (n,) yi = Y.values.flatten() # 转换为一维数组 (n,) wi = W.values.flatten() # 转换为一维数组 (n,) # 定义参数 n = 30 # 收集点数量(i=1..n,0为处理厂) K = 30 # 车辆总数 Q = 5 # 最大载重 # 计算距离矩阵dij(i,j=0..n) dij = np.zeros((n+1, n+1)) for i in range(n+1): for j in range(n+1): dij[i, j] = np.sqrt((xi[i] - xi[j])**2 + (yi[i] - yi[j])**2) x = cp.Variable((n+1, n+1, K), boolean=True) # x_ijv: 车辆v从i到j y = cp.Variable((n, K), boolean=True) # y_iv: 车辆v服务收集点i(i=1..n,索引0..n-1) z = cp.Variable(K, boolean=True) # z_v: 使用车辆v u = cp.Variable((n+1, K), nonneg=True) # u_iv: 车辆v访问i后的累计载重(i=0..n,u[0,v]=0) objective = cp.Minimize(cp.sum(cp.sum(cp.sum(dij @ x, axis=2), axis=1), axis=0)) # 约束条件 constraints = [] # 1. 每个收集点被 exactly 一辆车服务(i=1..n,对应y的索引0..n-1) for i in range(n): constraints.append(cp.sum(y[i, :]) == 1) # 2. 流量守恒(i=1..n,处理厂i=0的约束在6中) for i in range(1, n+1): # 收集点i(1..n,y索引i-1) for v in range(K): constraints.append(cp.sum(x[i, :, v]) == y[i-1, v]) # 离开i的次数等于服务i的次数 constraints.append(cp.sum(x[:, i, v]) == y[i-1, v]) # 进入i的次数等于服务i的次数 # 3. 载重约束 for v in range(K): constraints.append(cp.sum(wi * y[:, v]) <= Q * z[v]) # 4. MTZ约束(子回路消除) for v in range(K): constraints.append(u[0, v] == 0) # 处理厂出发时载重为0 for i in range(1, n+1): # 收集点i(1..n,wi[i-1]) constraints.append(u[i, v] >= wi[i-1]) # 载重下限 constraints.append(u[i, v] <= Q) # 载重上限 for j in range(1, n+1): if i != j: constraints.append(u[i, v] - u[j, v] + Q * x[i, j, v] <= Q - wi[j-1]) # 5. 车辆使用约束:服务收集点则使用车辆 for i in range(n): for v in range(K): constraints.append(y[i, v] <= z[v]) # 6. 出发返回约束(处理厂i=0,出发到收集点1..n,返回从收集点1..n到0) for v in range(K): constraints.append(cp.sum(x[0, 1:, v]) == z[v]) # 出发次数等于车辆使用 constraints.append(cp.sum(x[1:, 0, v]) == z[v]) # 返回次数等于车辆使用 # 建立问题并求解 problem = cp.Problem(objective, constraints) problem.solve() # 输出结果(示例,需根据实际需求处理) print("最优目标值:", problem.value) print("使用的车辆:", z.value)D:\python\python.exe D:\35433\Documents\数模练习\电工杯\问题1.py D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 1 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 2 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 3 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 4 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 5 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 6 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 7 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 8 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 9 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 10 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 11 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 12 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 13 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 14 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 15 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 16 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 17 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 18 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 19 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 20 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 21 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 22 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 23 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 24 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 25 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 26 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 27 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 28 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 29 times so far. D:\python\Lib\site-packages\cvxpy\expressions\expression.py:674: UserWarning: This use of ``*`` has resulted in matrix multiplication. Using ``*`` for matrix multiplication has been deprecated since CVXPY 1.1. Use ``*`` for matrix-scalar and vector-scalar multiplication. Use ``@`` for matrix-matrix and matrix-vector multiplication. Use ``multiply`` for elementwise multiplication. This code path has been hit 30 times so far. D:\python\Lib\site-packages\cvxpy\reductions\solvers\solving_chain_utils.py:41: UserWarning: The problem has an expression with dimension greater than 2. Defaulting to the SCIPY backend for canonicalization.