EADST

Maximize Sum with Unique Row and Column Numbers

Maximize the sum of the table where each number must come from the unique row and column. Maximum cost bipartite matching problem can be solved with the Hungarian algorithm.

from scipy.optimize import linear_sum_assignment
import numpy as np

cost =np.array(
    [
        [12,7,9,7,9],
        [8,9,6,6,6],
        [7,17,12,14,9],
        [15,14,6,6,10],
        [4,10,7,10,9]
    ])
row_ind, col_ind=linear_sum_assignment(cost)
res = np.zeros_like(cost) # np.ones_like
res[row_ind, col_ind] = 1
print(res)                          
#[[0 1 0 0 0]
# [0 0 1 0 0]
#[0 0 0 0 1]
#[0 0 0 1 0]
#[1 0 0 0 0]]
print(cost[row_ind,col_ind].sum())  # 32 total cost

Reference

StackOverflow

指派问题 —— 匈牙利算法

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
git CAM Permission Attention HaggingFace 递归学习法 论文速读 Docker 云服务器 Land Food Git Linux Input News Search COCO ResNet-50 Github Claude Math Tiktoken 多线程 报税 logger Tensor icon transformers OCR PDF Nginx tqdm 腾讯云 RAR Random ChatGPT SAM PDB mmap scipy InvalidArgumentError BeautifulSoup Web Breakpoint 公式 XML RGB Image2Text 算法题 FP32 Hungarian XGBoost Llama Rebuttal Quantization Hilton OpenCV Magnet Markdown Base64 Streamlit Diagram VGG-16 GPTQ Color Qwen Crawler 第一性原理 Clash Algorithm Heatmap Qwen2 Augmentation API Gemma FlashAttention Numpy Mixtral QWEN Conda 继承 Miniforge Card Sklearn FP8 强化学习 财报 CEIR HuggingFace Statistics CC IndexTTS2 Safetensors hf Website git-lfs Jupyter UI Interview Pillow PyCharm Password Video Dataset Data LeetCode llama.cpp Windows CUDA Django Logo GGML Python Firewall OpenAI 域名 ONNX FP16 SVR LoRA WebCrawler SPIE Plate Hotel LLM Translation Tracking UNIX NLP Bitcoin WAN Bin Anaconda 顶会 JSON BTC Michelin uWSGI Shortcut SQL CSV TensorFlow Use Zip SQLite Pandas TSV 版权 EXCEL NLTK Domain TTS GIT CTC Proxy Paddle DeepStream 音频 LLAMA 图标 搞笑 uwsgi C++ ModelScope Distillation printf 飞书 YOLO 净利润 签证 DeepSeek 多进程 Animate ms-swift 关于博主 FastAPI Freesound Review Cloudreve CV Jetson BF16 Transformers v0.dev VSCode 图形思考法 torchinfo 论文 Ubuntu FP64 GPT4 Paper Excel Vim AI PyTorch Qwen2.5 LaTeX Bipartite v2ray 阿里云 VPN Disk Ptyhon Plotly Pickle NameSilo Vmess diffusers MD5 Bert TensorRT GoogLeNet tar 证件照 Datetime Knowledge Quantize CLAP PIP Baidu Google Pytorch Agent Template
站点统计

本站现有博文330篇,共被浏览860913

本站已经建立2569天!

热门文章
文章归档
回到顶部