Index: bidspace/pom.xml
===================================================================
--- bidspace/pom.xml	(revision 1)
+++ bidspace/pom.xml	(revision 2)
@@ -42,5 +42,5 @@
 			<groupId>tudelft.utilities</groupId>
 			<artifactId>immutablelist</artifactId>
-			<version>1.0.0</version>
+			<version>1.0.1</version>
 		</dependency>
 
Index: bidspace/src/main/java/geniusweb/bidspace/BidsWithUtility.java
===================================================================
--- bidspace/src/main/java/geniusweb/bidspace/BidsWithUtility.java	(revision 2)
+++ bidspace/src/main/java/geniusweb/bidspace/BidsWithUtility.java	(revision 2)
@@ -0,0 +1,60 @@
+package geniusweb.bidspace;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import geniusweb.issuevalue.Bid;
+import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
+import tudelft.utilities.immutablelist.AbstractImmutableList;
+
+/**
+ * Object containing a subset of all bids, that have utility within given range.
+ */
+public class BidsWithUtility extends AbstractImmutableList<Bid> {
+
+	private final List<Bid> collectedbids;
+
+	/**
+	 * Create Bids with utility within given bounds.
+	 * 
+	 * @param space the {@link LinearAdditiveUtilitySpace} to search
+	 * @param min   the minimum required utility
+	 * @param max   the maximum required utility
+	 */
+	public BidsWithUtility(LinearAdditiveUtilitySpace space, BigDecimal min, BigDecimal max) {
+		this.collectedbids = new ArrayList<Bid>(getBids(space, min, max));
+	}
+
+	/**
+	 * Brute force hack for this time. Maybe we can construct this in a lazy way.
+	 * 
+	 * @param space
+	 * @param min
+	 * @param max
+	 * @return
+	 */
+	private List<Bid> getBids(LinearAdditiveUtilitySpace space, BigDecimal min, BigDecimal max) {
+		List<Bid> goodbids = new LinkedList<Bid>();
+		for (Bid bid : new AllBidsList(space.getDomain())) {
+			BigDecimal util = space.getUtility(bid);
+			if (util.compareTo(min) >= 0 && util.compareTo(max) <= 0) {
+				goodbids.add(bid);
+			}
+		}
+		return goodbids;
+	}
+
+	@Override
+	public Bid get(BigInteger index) {
+		return collectedbids.get(index.intValue());
+	}
+
+	@Override
+	public BigInteger size() {
+		return BigInteger.valueOf(collectedbids.size());
+	}
+
+}
Index: bidspace/src/main/java/geniusweb/bidspace/PartialSpaceFromUtility.java
===================================================================
--- bidspace/src/main/java/geniusweb/bidspace/PartialSpaceFromUtility.java	(revision 2)
+++ bidspace/src/main/java/geniusweb/bidspace/PartialSpaceFromUtility.java	(revision 2)
@@ -0,0 +1,91 @@
+package geniusweb.bidspace;
+
+import java.math.BigInteger;
+import java.security.SecureRandom;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import geniusweb.issuevalue.Bid;
+import geniusweb.profile.DefaultPartialOrdering;
+import geniusweb.profile.PartialOrdering;
+import geniusweb.profile.utilityspace.UtilitySpace;
+import tudelft.utilities.immutablelist.ListWithRemove;
+import tudelft.utilities.immutablelist.Tuple;
+import tudelft.utilities.immutablelist.Tuples;
+
+/**
+ * Simple demo converting a {@link UtilitySpace} into a {@link PartialOrdering}.
+ * Notice, a UtilitySpace IS a PartialOrdering, but a special one that is in
+ * fact a full ordering. This converter makes it a space that really has all
+ * info removed except for a few basic "isBetter" informations.
+ */
+public class PartialSpaceFromUtility extends DefaultPartialOrdering {
+	public PartialSpaceFromUtility(UtilitySpace space, int nRankings) {
+		super(space.getName() + "_" + nRankings, space.getDomain(), space.getReservationBid(),
+				pickBetter(space, nRankings));
+	}
+
+	/**
+	 * Pick subset of static isbetter rankings. Notice, ShuffledList currently can't
+	 * handle really large lists which also limits this. This has to be fixed.
+	 * 
+	 * @param space     the space to sample from
+	 * @param nRankings the number of rankings to be placed in the PartialOrdering.
+	 * @return a subset creating a partial profile of the geiven UtilitySpace
+	 */
+	private static Map<Bid, Set<Bid>> pickBetter(UtilitySpace space, int nRankings) {
+		Map<Bid, Set<Bid>> eqOrBetter = new HashMap<>();
+
+		AllBidsList allbids = new AllBidsList(space.getDomain());
+		ListWithRemove<Tuple<Bid, Bid>> available = new ListWithRemove<>(new Tuples<Bid, Bid>(allbids, allbids));
+		for (int n = 0; n < nRankings; n++) {
+			BigInteger sel = rnd(available.size());
+			Tuple<Bid, Bid> tuple = available.get(sel);
+			Bid bid1 = tuple.get1();
+			Bid bid2 = tuple.get2();
+			switch (space.getUtility(bid1).compareTo(space.getUtility(bid2))) {
+			case -1: // bid1 is worse
+				add(eqOrBetter, bid2, bid1);
+				break;
+			case 0:
+				add(eqOrBetter, bid2, bid1);
+				add(eqOrBetter, bid1, bid2);
+				break;
+			case 1:// bid1 is better
+				add(eqOrBetter, bid1, bid2);
+				break;
+			}
+			available = available.remove(sel);
+		}
+		return eqOrBetter;
+	}
+
+	/**
+	 * 
+	 * @param eqOrBetter map to be extended with (key=bid1, value=bid2)
+	 * @param bid1       the key to add a value to
+	 * @param bid2       the value to be added
+	 */
+	private static void add(Map<Bid, Set<Bid>> eqOrBetter, Bid bid1, Bid bid2) {
+		Set<Bid> set = eqOrBetter.get(bid1);
+		if (set == null) {
+			set = new HashSet<Bid>();
+		}
+		set.add(bid2);
+		eqOrBetter.put(bid1, set);
+	}
+
+	/**
+	 * Bit simplistic way to generate random in [0,n>. Simplistic because the mod()
+	 * operator that we use causes bias in the random numbers.
+	 * 
+	 * @param n the maximum value for the random number
+	 * @return random in [0,n>
+	 * 
+	 */
+	private static final BigInteger rnd(BigInteger n) {
+		return new BigInteger(n.bitLength(), new SecureRandom()).mod(n);
+	}
+}
Index: bidspace/src/test/java/geniusweb/bidspace/BidsWithUtilityTest.java
===================================================================
--- bidspace/src/test/java/geniusweb/bidspace/BidsWithUtilityTest.java	(revision 2)
+++ bidspace/src/test/java/geniusweb/bidspace/BidsWithUtilityTest.java	(revision 2)
@@ -0,0 +1,100 @@
+package geniusweb.bidspace;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import geniusweb.issuevalue.Bid;
+import geniusweb.issuevalue.DiscreteValue;
+import geniusweb.issuevalue.DiscreteValueSet;
+import geniusweb.issuevalue.Domain;
+import geniusweb.issuevalue.NumberValue;
+import geniusweb.issuevalue.NumberValueSet;
+import geniusweb.issuevalue.ValueSet;
+import geniusweb.profile.Profile;
+import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
+
+public class BidsWithUtilityTest {
+	private static final DiscreteValue I1V2 = new DiscreteValue("i1v2");
+	private static final DiscreteValue I1V1 = new DiscreteValue("i1v1");
+	private static final NumberValue I2V1 = new NumberValue("2.00");
+	private static final NumberValue I2V2 = new NumberValue("2.45");
+	private static final NumberValue I2V3 = new NumberValue("2.90");
+	private static final String DOMAINNAME = "testdomain";
+	private static final String ISSUE1 = "issue1";
+	private static final String ISSUE2 = "issue2";
+	private static final Map<String, ValueSet> issues = new HashMap<>();
+
+	private static ValueSet values1;
+	private static ValueSet values2;
+	private static final BigDecimal TWO = new BigDecimal("2");
+	private static final BigDecimal THREE = new BigDecimal("3");
+	private final static BigDecimal ZERO_1 = new BigDecimal("0.1"), ZERO_2 = new BigDecimal("0.2"),
+			ZERO_3 = new BigDecimal("0.3");
+
+	private static Domain domain;
+	private final static ObjectMapper jackson = new ObjectMapper();
+
+	@Before
+	public void before() {
+		Collection<DiscreteValue> discretevalues1 = new LinkedList<>();
+		discretevalues1.add(I1V1);
+		discretevalues1.add(I1V2);
+		values1 = new DiscreteValueSet(discretevalues1);
+		issues.put(ISSUE1, values1);
+
+		values2 = new NumberValueSet(TWO, THREE, new BigDecimal("0.45"));
+		issues.put(ISSUE2, values2);
+
+		domain = new Domain(DOMAINNAME, issues);
+
+	}
+
+	@Test
+	public void smokeTest() {
+		LinearAdditiveUtilitySpace space = mock(LinearAdditiveUtilitySpace.class);
+		when(space.getDomain()).thenReturn(domain);
+		when(space.getUtility(any(Bid.class))).thenReturn(ZERO_2);
+		new BidsWithUtility(space, new BigDecimal("0.1"), new BigDecimal("0.3"));
+	}
+
+	@Test
+	public void testSelection() {
+		LinearAdditiveUtilitySpace space = mock(LinearAdditiveUtilitySpace.class);
+
+		when(space.getDomain()).thenReturn(domain);
+		when(space.getUtility(any(Bid.class))).thenReturn(ZERO_2);
+		BidsWithUtility selected = new BidsWithUtility(space, new BigDecimal("0.1"), new BigDecimal("0.3"));
+		assertEquals(new BigInteger("6"), selected.size());
+	}
+
+	@Test
+	public void testRealSpace() throws IOException {
+		String file1 = new String(Files.readAllBytes(Paths.get("src/test/resources/jobs/jobs1.json")));
+		LinearAdditiveUtilitySpace profile = (LinearAdditiveUtilitySpace) jackson.readValue(file1, Profile.class);
+		BidsWithUtility selected = new BidsWithUtility(profile, ZERO_1, ZERO_3);
+
+		assertEquals(new BigInteger("56"), selected.size());
+		for (Bid bid : selected) {
+			assertEquals(1, profile.getUtility(bid).compareTo(ZERO_1));
+			assertEquals(-1, profile.getUtility(bid).compareTo(ZERO_3));
+		}
+	}
+
+}
Index: bidspace/src/test/java/geniusweb/bidspace/PartialSpaceFromUtilityTest.java
===================================================================
--- bidspace/src/test/java/geniusweb/bidspace/PartialSpaceFromUtilityTest.java	(revision 2)
+++ bidspace/src/test/java/geniusweb/bidspace/PartialSpaceFromUtilityTest.java	(revision 2)
@@ -0,0 +1,27 @@
+package geniusweb.bidspace;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import geniusweb.profile.Profile;
+import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
+
+public class PartialSpaceFromUtilityTest {
+	private final static ObjectMapper jackson = new ObjectMapper();
+
+	@Test
+	public void createPartialSpaceJobs() throws IOException {
+		String file1 = new String(Files.readAllBytes(Paths.get("src/test/resources/jobs/jobs1.json")));
+		LinearAdditiveUtilitySpace profile = (LinearAdditiveUtilitySpace) jackson.readValue(file1, Profile.class);
+		PartialSpaceFromUtility partial = new PartialSpaceFromUtility(profile, 20);
+		System.out.println(jackson.writeValueAsString(partial));
+		assertEquals(20, partial.getBetter().size());
+	}
+}
