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

本站现有博文321篇,共被浏览775263

本站已经建立2465天!

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