Python Forum
Help Getting Started - Optimisation Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Getting Started - Optimisation Problem
#1
Hi all

I am getting stuck having searched for about an hour through various forums, Stack oveflow posts and online articles!

I have a simple CSV file which has three columns: baseline-id, comparison-id and score.

[Image: yX2fCMD]


The file contains every possible combination of baseline-id and comparison-id, so I have already done the 'permutations' to get all the possible score.

There are 191 baseline-ids and 196 comparison-ids, so 37.4k permutations.

I'd now like to 'optimise' this to get the maximum score. The only constraint that I have is to make sure that I do not use an ID more than once. Ideally, my results should have the 191 distinct baseline-ids, a distinct comparison-id (cannot use the same id twice) and the score.

I cannot find an accessible tutorial for this but expect this is because I am not quite sure what to search for.

Thanks for any help!!
Reply
#2
We probably give 'optimise' a different meaning. For me optimising means that I have working code which delivers expected results but is too slow and I have to refactor it.

Simple brute-force (not optimised) idea: read the file with csv.DictReader into list of dictionaries, find unique pair values of baseline/comparison id-s using set comprehension and find maximum value for every unique pair using list comprehesion. This is very brute force but should deliver desired result.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot get started standenman 4 1,150 Feb-22-2023, 05:25 PM
Last Post: standenman
  Need help i just started the whole thing gabriel789 16 3,098 Sep-12-2022, 08:04 PM
Last Post: snippsat
  Can't even get started dr6 1 1,587 Aug-18-2020, 04:38 PM
Last Post: Larz60+
  Optimisation H0M1C1D4L_P1G 3 2,676 Dec-23-2019, 11:44 PM
Last Post: ichabod801
  Optimisation problem - star identification pberrett 1 2,232 Apr-01-2019, 12:17 AM
Last Post: scidam
  Getting started mba_110 0 1,700 Jan-18-2019, 05:23 PM
Last Post: mba_110
  Getting Started wargasme 5 3,363 Jun-19-2018, 07:25 PM
Last Post: ichabod801
  Just getting started alwillia 6 3,531 May-20-2018, 07:22 PM
Last Post: ljmetzger

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020