TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Solve the best fantasy team with MiniZinc

3 pointsby d0m3over 1 year ago
It&#x27;s the rugby world cup at the moment, and there is a fantasy game for it. Someone started posting the best possible team after each round and I thought &quot;how could I automate this?&quot;. I recalled a post I read here (<a href="https:&#x2F;&#x2F;www.hillelwayne.com&#x2F;post&#x2F;np-hard&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.hillelwayne.com&#x2F;post&#x2F;np-hard&#x2F;</a>) and that&#x27;s where I found a reference to MiniZinc. I gave it a go and although it&#x27;s not that easy to learn using only the docs, I was pleasantly surprised that I managed to make it work in less than a day. Pretty fun to play with the constraints to get different results and develop an understanding of what matters to pick a good team. The constraints are the following: - only 3 players per country - can&#x27;t exceed a maximum budget based on each player cost - players have to be picked in their official position and there is a different number of slots for each position (8 positions, 15 slots) Happy to get some feedback and perhaps it can inspire others!

1 comment

mzlover 1 year ago
Interesting model! Testing it locally, I could see that one issue in the model is that there is a lot of symmetry to the results. Enforcing that players in the team are ordered was not useful and did not help. Enforcing that the team positions were ordered helped a lot though, by extracting the `[position[p] | p in team]` expression as a separate array `team_position` and enforcing increasing on it.<p>With HiGHS the solve-time went from 1m7s on my machine (M1 Max) to just 7.23s. The model is solved at the root node with this change, as opposed to 1430 nodes without it.<p>Using OR-Tools 9.7 with free search enabled (see Configuration editor in the MiniZinc IDE) with the new model took 10.3 seconds. With 10 threads it is solved in 1.56s.
评论 #37646093 未加载