首页 > 解决方案 > 如何在 Julia 中制作 inf 矩阵?

问题描述

我想将我的问题的最低边界设置为 -inf 也没有限制,这里是代码

@time begin
using COSMO, SparseArrays, LinearAlgebra
using NPZ

Matrix10 = npzread("C:/Users/skqkr/Desktop/Semesterarbeit/Chiwan_Q1.npz")
q = Matrix10["p"];
P = sparse(Matrix10["Q"]);
A = sparse(Matrix10["G"]);
h = Matrix10["h"];
l = Matrix10["l"];

# First, we decide to solve the problem with two one-sided constraints using `COSMO.Nonnegatives` as the convex set:
Aa = [-A; A]
ba = [h; -l]
constraint1 = COSMO.Constraint(Aa, ba, COSMO.Nonnegatives);

# Next, we define the settings object, the model and then assemble everything:
settings = COSMO.Settings(verbose=true);
model = COSMO.Model();
assemble!(model, P, q, constraint1, settings = settings);
res = COSMO.optimize!(model);


# Alternatively, we can also use two-sided constraints with `COSMO.Box`:
constraint1 = COSMO.Constraint(A, zeros(3), COSMO.Box(-l, h));

model = COSMO.Model();
assemble!(model, P, q, constraint1, settings = settings);
res_box = COSMO.optimize!(model);



end

所以我想要

l = Matrix10["l"];

这里 ll 作为一个没有限制的矩阵,所以 qp 的约束将是这种形式。A*X<h

我应该怎么做才能使限制减去无穷大。

谢谢你!!

标签: juliaquadratic-programming

解决方案


推荐阅读