我喜欢在IJulia笔记本上工作,并希望一遍又一遍地在同一行上打印某些流程的状态.
以下面链接中给出的示例为例,我们需要一些输出:
Downloading File FooFile.txt [47%]
Run Code Online (Sandbox Code Playgroud)
并希望避免这样的事情:
Downloading File FooFile.txt [47%]
Downloading File FooFile.txt [48%]
Downloading File FooFile.txt [49%]
Run Code Online (Sandbox Code Playgroud)
在Python的情况下,我在这里找到了答案.
什么是解决方案?
我正在尝试解决一个简单的优化问题,我们想要一个复数值的 Hermitan 矩阵,因为它是可变的(主题是量子力学)
using Convex #load the optimization solvers
using SCS
# define pauli-y+ projector
# by construction a positive operator valued hermitian matrix
y_plus = [1,im]/sqrt(2)
My0 = y_plus*y_plus'
# define the variable; a 2x2 density matrix
rho = Variable(2, 2)
problem.constraints += [rho == rho'] # hermitian
problem.constraints += [trace(rho) == 1] # unit trace
problem.constraints += [rho in :SDP] # positive definite
# define the objective
problem = maximize(trace(rho*My0))
# solve
solve!(problem,SCSSolver(verbose=false))
problem.optval
Run Code Online (Sandbox Code Playgroud)
问题是,Julia/JuMP/Convex.jl 都会报错
maximize(trace(rho*My0))
Run Code Online (Sandbox Code Playgroud)
由于跟踪 …