メインコンテンツへスキップ

How to add L1 norm as a constraint in PCA

回答済み

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Matthias Miltenberger
    • Gurobi Staff

    Hi Alvaro,

    You need to write the L1 constraints like this:

    for v, absv in zip(weights, abs_weights):
    pca_gurobi.addConstr(abs_weights[absv] == gp.abs_(weights[v]))

    Please note that looping over the variable dicts will generate index objects as looping variables, so you need to use those to specify the actual decision variables in the respective dicts weights and abs_weights.

    The error message here is quite misleading because the input data for the addConstr call doesn't contain a variable.

    I hope that helps.

    Cheers,
    Matthias

    0

投稿コメントは受け付けていません。