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

本站现有博文320篇,共被浏览756667

本站已经建立2420天!

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