Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:14:50+00:00 2026-06-12T17:14:50+00:00

Say I have a Group data structure which contains a list of Element objects,

  • 0

Say I have a Group data structure which contains a list of Element objects, such that each group has a unique set of elements.:

public class Group
{
  public List<Element> Elements;
}

and say I have a list of populations who require certain elements, in such a way that each population has a unique set of required elements:

public class Population
{
  public List<Element> RequiredElements;
}

I have an unlimited quantity of each defined Group, i.e. they are not consumed by populations.

Say I am looking at a particular Population. I want to find the best possible match of groups such that there is minimum excess elements, and no unmatched elements.

For example: I have a population which needs wood, steel, grain, and coal. The only groups available are {wood, herbs}, {steel, coal, oil}, {grain, steel}, and {herbs, meat}.

The last group – {herbs, meat} isn’t required at all by my population so it isn’t used. All others are needed, but herbs and oil are not required so it is wasted. Furthermore, steel exists twice in the minimum set, so one lot of steel is also wasted. The best match in this example has a wastage of 3.

So for a few hundred Population objects, I need to find the minimum wastage best match and compute how many elements are wasted.

How do I even begin to solve this? Once I have found a match, counting the wastage is trivial. Finding the match in the first place is hard. I could enumerate all possibilities but with a few thousand populations and many hundreds of groups, it’s quite a task. Especially considering this whole thing sits inside each iteration of a simulated annealing algorithm.

I’m wondering whether I can formulate the whole thing as a mixed-integer program and call a solver like GLPK at each iteration.

I hope I have explained the problem correctly. I can clarify anything that’s unclear.


Here’s my binary program, for those of you interested…

x is the decision vector, an element of {0,1}, which says that the population in question does/doesn’t receive from group i. There is an entry for each group.

b is the column vector, an element of {0,1}, which says which resources the population in question does/doesn’t need. There is an entry for each resource.

A is a matrix, an element of {0,1}, which says what resources are in what groups.

The program is:

Minimise: ((Ax – b)’ * 1-vector) + (x’ * 1-vector);

Subject to: Ax >= b;

The constraint just says that all required resources must be satisfied. The objective is to minimise all excess and the total number of groups used. (i.e. 0 excess with 1 group used is better than 0 excess with 5 groups used).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:14:51+00:00Added an answer on June 12, 2026 at 5:14 pm

    You can formulate an integer program for each population P as follows. Use a binary variable xj to denote whether group j is chosen or not. Let A be a binary matrix, such that Aij is 1 if and only if item i is present in group j. Then the integer program is:

    min Ei,j (xjAij)

    s.t. Ej xjAij >= 1 for all i in P.

    xj = 0, 1 for all j.

    Note that you can obtain the minimum wastage by subtracting |P| from the optimal solution of the above IP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a List<Pet> and each Pet has a Pet.Name and Pet.Type
Simple (I hope), HTML question. Let's say I have a column group that spans
say i have a list of items which some of them are similiar up
Say I have a table transactions that has columns acct_id trans_date and trans_type and
Let's say I have the following hypothetical data structure: create table country ( country_id
Say you have columns AppleType, CreationDate and want to order each group of AppleType
Say I have a group of struct's that I want to manage arrays of
Let's say I have two entities: Group and User. Every user can be member
Lets say I have a table: -------------------------------------- | ID | DATE | GROUP |
Let's say I have a large database that consists of products in groups. Let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.