Index: /pom.xml
===================================================================
--- /pom.xml	(revision 7)
+++ /pom.xml	(revision 8)
@@ -52,4 +52,11 @@
 			<version>1.1.0</version>
 		</dependency>
+		
+				<dependency>
+			<groupId>geniusweb</groupId>
+			<artifactId>bidspace</artifactId>
+			<version>1.1.0</version>
+		</dependency>
+		
 
 		<dependency>
Index: /src/main/java/geniusweb/profilesserver/AutoUpdatingProfilesFactory.java
===================================================================
--- /src/main/java/geniusweb/profilesserver/AutoUpdatingProfilesFactory.java	(revision 7)
+++ /src/main/java/geniusweb/profilesserver/AutoUpdatingProfilesFactory.java	(revision 8)
@@ -9,6 +9,4 @@
 import java.util.List;
 import java.util.logging.Level;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 import geniusweb.issuevalue.Domain;
@@ -42,4 +40,5 @@
 public class AutoUpdatingProfilesFactory extends DefaultProfilesFactory {
 
+	private static final String PROFILES_ROOTDIR = "PROFILES_ROOTDIR";
 	private static final String DOMAINSREPO = "domainsrepo";
 	private static final String JSON = ".json";
@@ -47,5 +46,4 @@
 	private Path rootdir;
 	private final Reporter log;
-	private static final ObjectMapper jackson = new ObjectMapper();
 
 	public AutoUpdatingProfilesFactory(Reporter logger) {
@@ -217,5 +215,5 @@
 		Profile profile = null;
 		try {
-			profile = jackson.readValue(profilefile, Profile.class);
+			profile = Jackson.instance().readValue(profilefile, Profile.class);
 		} catch (IOException e) {
 			log.log(Level.WARNING, "File " + profilefile
@@ -250,5 +248,5 @@
 		String expectedName = withoutExtension(domainfile.getName());
 		try {
-			domain = jackson.readValue(domainfile, Domain.class);
+			domain = Jackson.instance().readValue(domainfile, Domain.class);
 		} catch (IOException e) {
 			log.log(Level.WARNING, "File " + domainfile
@@ -341,4 +339,12 @@
 		// Search back upwards to projectroot.
 		Path dir;
+		String path = System.getenv(PROFILES_ROOTDIR);
+		if (path != null) {
+			dir = Paths.get(path);
+			if (!dir.toFile().exists())
+				throw new RuntimeException("Hard set path PROFILES_ROOTDIR='"
+						+ PROFILES_ROOTDIR + "' does not exist ");
+			return dir;
+		}
 		try {
 			dir = Paths.get(getClass().getProtectionDomain().getCodeSource()
@@ -355,6 +361,5 @@
 			dir = dir.getParent();
 		}
-		return Paths.get(DOMAINSREPO); // bit silly, it's not there, but we need
-										// to do something.
+		throw new RuntimeException("Path to " + DOMAINSREPO + " was not found");
 	}
 
Index: /src/main/java/geniusweb/profilesserver/Jackson.java
===================================================================
--- /src/main/java/geniusweb/profilesserver/Jackson.java	(revision 8)
+++ /src/main/java/geniusweb/profilesserver/Jackson.java	(revision 8)
@@ -0,0 +1,22 @@
+package geniusweb.profilesserver;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * A central generator for the object mapper, so that we can extend the
+ * objectmapper (with custom classes) centrally. Also allows us to cache the
+ * objectmapper.
+ * 
+ * <b> This class should is private to the profiles server and should not be
+ * used by others.
+ */
+public class Jackson {
+	private static ObjectMapper jackson;
+
+	public static ObjectMapper instance() {
+		if (jackson == null) {
+			jackson = new ObjectMapper();
+		}
+		return jackson;
+	}
+}
Index: /src/main/java/geniusweb/profilesserver/websocket/GetProfileSocket.java
===================================================================
--- /src/main/java/geniusweb/profilesserver/websocket/GetProfileSocket.java	(revision 7)
+++ /src/main/java/geniusweb/profilesserver/websocket/GetProfileSocket.java	(revision 8)
@@ -2,4 +2,14 @@
 
 import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.websocket.OnClose;
@@ -10,9 +20,16 @@
 import javax.websocket.server.ServerEndpoint;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-
+import geniusweb.bidspace.AllBidsList;
+import geniusweb.bidspace.BidsWithUtility;
+import geniusweb.issuevalue.Bid;
+import geniusweb.profile.DefaultPartialOrdering;
+import geniusweb.profile.PartialOrdering;
 import geniusweb.profile.Profile;
+import geniusweb.profile.utilityspace.LinearAdditive;
+import geniusweb.profilesserver.Jackson;
 import geniusweb.profilesserver.ProfilesFactory;
 import geniusweb.profilesserver.events.ChangeEvent;
+import tudelft.utilities.immutablelist.FixedList;
+import tudelft.utilities.immutablelist.ImmutableList;
 import tudelft.utilities.listener.Listener;
 
@@ -22,8 +39,17 @@
  * profiles is sent. For each new websocket the server will create one of this
  * but they all share one {@link ProfilesFactory}.
+ * 
+ * <p>
+ * Query string: the websocket allows query strings.
+ * <ul>
+ * <li>partial</li> a query key that is assigned a natural number N (0 or
+ * larger). If set, the profile is converted into a Partial Profile with the
+ * given number of points. If N>0, the maximum utility bid is included .If N>1,
+ * the minimum utility bid is included. The other bids are picked at random.
+ * This filtering mechanism only works if the profile is {@link LinearAdditive}
+ * space.
  */
 @ServerEndpoint("/websocket/get/{domain}/{profile}")
 public class GetProfileSocket {
-	private final static ObjectMapper jackson = new ObjectMapper();
 	private Profile prof = null; // the latest that we sent to client.
 
@@ -33,4 +59,5 @@
 	private Listener<ChangeEvent> changeListener;
 	private Session session;
+	private Map<String, String> params = Collections.emptyMap();
 
 	@OnOpen
@@ -40,4 +67,10 @@
 		this.profilename = domain + "/" + profile;
 
+		if (session.getQueryString() != null) {
+			List<String> paramstrings = Arrays
+					.asList(session.getQueryString().split("&"));
+			params = paramstrings.stream().map(str -> str.split("=")).collect(
+					Collectors.toMap(vals -> vals[0], vals -> vals[1]));
+		}
 		changeListener = new Listener<ChangeEvent>() {
 			@Override
@@ -56,10 +89,67 @@
 			prof = newprof;
 			try {
-				session.getBasicRemote()
-						.sendText(jackson.writeValueAsString(prof));
+				session.getBasicRemote().sendText(
+						Jackson.instance().writeValueAsString(filter(prof)));
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
 		}
+	}
+
+	private Profile filter(Profile prof1) {
+		String partial = params.get("partial");
+		if (partial == null) {
+			return prof1;
+		}
+		if (!(prof1 instanceof PartialOrdering))
+			throw new IllegalArgumentException(
+					"profile must be partialordering but got " + prof);
+		PartialOrdering profile = (PartialOrdering) prof1;
+		final int numbids = Integer.parseInt(partial);
+		if (numbids < 0)
+			throw new IllegalArgumentException("parameter partial must be >=0");
+
+		ImmutableList<Bid> allbids;
+		if (profile instanceof DefaultPartialOrdering)
+			allbids = new FixedList<Bid>(
+					((DefaultPartialOrdering) profile).getBids());
+		else
+			allbids = new AllBidsList(prof.getDomain());
+
+		if (BigInteger.valueOf(numbids).compareTo(allbids.size()) > 0)
+			throw new IllegalArgumentException("Request for " + numbids
+					+ " exceeds number of bids in the space " + allbids.size());
+
+		BidsWithUtility info = new BidsWithUtility((LinearAdditive) prof);
+		Set<Bid> selected = new HashSet<>();
+		if (numbids > 0) {
+			selected.add(info.getExtremeBid(true));
+		}
+		if (numbids > 1) {
+			selected.add(info.getExtremeBid(false));
+		}
+		Random random = new Random();
+		for (int nr = 2; nr < numbids; nr++) {
+			int attempt = 0;
+			Bid bid;
+			do {
+				long i = random.nextInt(allbids.size().intValue());
+				bid = allbids.get(BigInteger.valueOf(i));
+			} while (attempt++ < 10 && selected.contains(bid));
+			selected.add(bid);
+		}
+
+		// put comparison info for these bids in the map
+		Map<Bid, Set<Bid>> isBetterMap = new HashMap<>();
+		for (Bid bid : selected) {
+			Set<Bid> worse = selected.stream().filter(
+					otherbid -> profile.isPreferredOrEqual(bid, otherbid)
+							&& !profile.isPreferredOrEqual(otherbid, bid))
+					.collect(Collectors.toSet());
+			isBetterMap.put(bid, worse);
+		}
+		return new DefaultPartialOrdering(
+				prof.getName() + "-partial-" + numbids, prof.getDomain(),
+				prof.getReservationBid(), isBetterMap);
 	}
 
Index: /src/main/java/geniusweb/profilesserver/websocket/ProfilesListSocket.java
===================================================================
--- /src/main/java/geniusweb/profilesserver/websocket/ProfilesListSocket.java	(revision 7)
+++ /src/main/java/geniusweb/profilesserver/websocket/ProfilesListSocket.java	(revision 8)
@@ -24,6 +24,5 @@
 import javax.websocket.server.ServerEndpoint;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-
+import geniusweb.profilesserver.Jackson;
 import geniusweb.profilesserver.ProfilesFactory;
 import geniusweb.profilesserver.events.ChangeEvent;
@@ -83,5 +82,5 @@
 		log.log(Level.FINER, "sending updated profiles");
 		session.getBasicRemote().sendText(
-				new ObjectMapper().writeValueAsString(getDomainsProfiles()));
+				Jackson.instance().writeValueAsString(getDomainsProfiles()));
 	}
 
Index: /src/test/java/geniusweb/profilesserver/AutoUpdatingProfilesFactoryTest.java
===================================================================
--- /src/test/java/geniusweb/profilesserver/AutoUpdatingProfilesFactoryTest.java	(revision 7)
+++ /src/test/java/geniusweb/profilesserver/AutoUpdatingProfilesFactoryTest.java	(revision 8)
@@ -44,4 +44,5 @@
  */
 public class AutoUpdatingProfilesFactoryTest {
+
 	private static final String JOBS = "jobs";
 	private static final String JOB1 = "jobs/jobs1";
@@ -242,4 +243,13 @@
 	}
 
+	@Test
+	public void testEnvVariable() throws IOException {
+		Path dir = Files.createTempDirectory("tempdir");
+		// This test does not work because we can not set the env variable.
+		// new EnvironmentVariables().set("PROFILES_ROOTDIR", "1");
+		System.setProperty("PROFILES_ROOTDIR", "1");// dir.toAbsolutePath().toString());
+		System.out.println(System.getenv("PROFILES_ROOTDIR"));
+	}
+
 	/**
 	 * Copy files and all sub-files.
