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

本站现有博文323篇,共被浏览800143

本站已经建立2499天!

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