Codota Logo
Household
Code IndexAdd Codota to your IDE (free)

How to use
Household
in
org.matsim.households

Best Java code snippets using org.matsim.households.Household (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: matsim-org/matsim

public HouseholdBasedVehicleRessources(
    final Households hhs) {
  this.households = hhs;
  for (Household hh : hhs.getHouseholds().values()) {
    final Id hhId = hh.getId();
    for (Id agentId : hh.getMemberIds()) {
      agent2hh.put( agentId , hhId );
    }
  }
}
origin: matsim-org/matsim

  @Override
  public Set<Id<Vehicle>> identifyVehiclesUsableForAgent(final Id<Person> person) {
    // we can't simply remember an agent->hh mapping at construction,
    // as the households container is mutable. It would not make any sense
    // to modify it, but one is never too prudent.
    final Id<Household> hhId = agent2hh.get( person );
    if ( hhId == null ) throw new RuntimeException( "no household known for "+person );

    final Household hh = households.getHouseholds().get( hhId );
    if ( hh == null ) throw new RuntimeException( "household "+hhId+" vanished!" );
    if ( !hh.getMemberIds().contains( person ) ) throw new RuntimeException( "household "+hhId+" does not contain "+person );

    return new HashSet<Id<Vehicle>>( hh.getVehicleIds() );
  }
}
origin: matsim-org/matsim

@Override
public int compare(Household o1, Household o2) {
  if (o1.getIncome().getIncomePeriod() != o2.getIncome().getIncomePeriod()){
    throw new IllegalArgumentException("Can only compare Households with incomes in "
        + " same income period");
  }
  if (o1.getIncome().getIncome() < o2.getIncome().getIncome()){
    return -1;
  }
  else if (o1.getIncome().getIncome() > o2.getIncome().getIncome()){
    return 1;
  }
  return 0;
}
origin: matsim-org/matsim

/*package*/ void writeHousehold(Household h) throws UncheckedIOException {
  this.atts.clear();
  atts.add(createTuple(HouseholdsSchemaV10Names.ID, h.getId().toString()));
  this.writeStartTag(HouseholdsSchemaV10Names.HOUSEHOLD, atts);
  if ((h.getMemberIds() != null) && !h.getMemberIds().isEmpty()){
    this.writeMembers(h.getMemberIds());
  }
  if ((h.getVehicleIds() != null) && !h.getVehicleIds().isEmpty()) {
    this.writeStartTag(HouseholdsSchemaV10Names.VEHICLES, null);
    for (Id<Vehicle> id : h.getVehicleIds()){
      atts.clear();
      atts.add(createTuple(HouseholdsSchemaV10Names.REFID, id.toString()));
      this.writeStartTag(HouseholdsSchemaV10Names.VEHICLEDEFINITIONID, atts, true);
    }
    this.writeEndTag(HouseholdsSchemaV10Names.VEHICLES);
  }
  if (h.getIncome() != null){
    this.writeIncome(h.getIncome());
  }
  AttributesXmlWriterDelegate attributesWriter = new AttributesXmlWriterDelegate();
  attributesWriter.putAttributeConverters(this.attributeConverters);
  try {
    this.writer.write(NL);
  } catch (IOException e) {
    e.printStackTrace();
  }
  attributesWriter.writeAttributes( "\t\t" , this.writer , h.getAttributes() );
  this.writeEndTag(HouseholdsSchemaV10Names.HOUSEHOLD);
}
origin: matsim-org/matsim

/**
 * Adds the household to the container. If streaming is set, the household
 * is added, the algorithms are run on the household, and it is subsequently
 * removed. If not, the household is added incrementally to the container.
 * @param household
 * @throws IllegalArgumentException if the container already includes the 
 *         {@link Id} of the household being added.
 */
public final void addHousehold(final Household household){
  /* Validate that a household with the same Id does not exist yet. */
  if(this.getHouseholds().containsKey(household.getId())){
    throw new IllegalArgumentException("Household with Id " + household.getId() + 
        " already exisits.");
  }
  this.households.put(household.getId(), household);
}

origin: matsim-org/matsim

public void reinitialize(Households hhs) {
  this.phMap.clear();
  for (Household h : hhs.getHouseholds().values()){
    for (Id<Person> member : h.getMemberIds()){
      this.phMap.put(member, h);
    }
  }
  
}

origin: matsim-org/matsim

currAttributes = this.currentHousehold.getAttributes();
attributesReader.startTag( name , atts , context, currAttributes );
origin: matsim-org/matsim

private void fillHousehold() {
  ((HouseholdImpl) this.currentHousehold).setMemberIds(this.currentmembers);
  ((HouseholdImpl) this.currentHousehold).setVehicleIds(this.currentVehicleIds);
  this.currentHousehold.setIncome(this.currentincome);
  this.currentHhId = null;
  this.currentVehicleIds = null;
  this.currentincome = null;
  this.currentmembers = null;
  this.currentIncomePeriod = null;
  this.currentincomeCurrency = null;
}
origin: matsim-org/matsim

Household hh = households.getHouseholds().get(id23);
assertNotNull(hh);
assertEquals(id23, hh.getId());
assertEquals(3, hh.getMemberIds().size());
List<Id<Person>> hhmemberIds = new ArrayList<>();
hhmemberIds.addAll(hh.getMemberIds());
Collections.sort(hhmemberIds);
assertEquals(pid23, hhmemberIds.get(0));
assertNotNull(hh.getVehicleIds());
List<Id<Vehicle>> vehIds = new ArrayList<>();
vehIds.addAll(hh.getVehicleIds());
Collections.sort(vehIds);
assertEquals(2, vehIds.size());
assertNotNull(hh.getIncome());
assertNotNull(hh.getIncome().getIncomePeriod());
assertEquals(IncomePeriod.month, hh.getIncome().getIncomePeriod());
assertEquals("eur", hh.getIncome().getCurrency());
assertEquals(50000.0d, hh.getIncome().getIncome(), EPSILON);
Attributes currentAttributes = hh.getAttributes();
assertNotNull("Custom attributes from household with id 23 should not be empty.", currentAttributes);
String customAttributeName = "customAttribute1";
assertEquals(id24, hh.getId());
assertEquals(2, hh.getMemberIds().size());
assertEquals(pid44, hh.getMemberIds().get(0));
assertEquals(pid45, hh.getMemberIds().get(1));
origin: matsim-org/matsim

public void runAlgorithms(Household h){
  for(HouseholdAlgorithm algorithm : this.householdAlgorithms){
    log.info("Running algorithm " + algorithm.getClass().getName() + " on household " + h.getId());
    algorithm.run(h);
  }        
}

origin: matsim-org/matsim

private static Collection<? extends Collection<Id<Person>>> extractGroups(
    final Households households) {
  final List<List<Id<Person>>> groups = new ArrayList<>();
  for ( Household hh : households.getHouseholds().values() ) {
    groups.add( hh.getMemberIds() );
  }
  return groups;
}
origin: matsim-org/matsim

/*package*/ Household createHousehold() {
  Household hh = this.builder.createHousehold(this.currentHhId);
  ((HouseholdImpl) hh).setMemberIds(this.currentmembers);
  ((HouseholdImpl) hh).setVehicleIds(this.currentVehicleIds);
  hh.setIncome(this.currentincome);
  this.currentHhId = null;
  this.currentVehicleIds = null;
  this.currentincome = null;
  this.currentmembers = null;
  this.currentIncomePeriod = null;
  this.currentincomeCurrency = null;
  return hh;
}
origin: matsim-org/matsim

/**
 * Test that households with the same {@link Id} are not accepted.
 */
public void testAddHousehold_DuplicateId(){
  HouseholdsImpl hhs = new HouseholdsImpl();
  Household hh1 = new HouseholdImpl(Id.create("1", Household.class));
  Household hh2 = new HouseholdImpl(Id.create("1", Household.class));
  
  assertEquals("Shouldn't have a household.", 0, hhs.getHouseholds().size());
  hhs.addHousehold(hh1);
  assertEquals("Didn't add the household.", 1, hhs.getHouseholds().size());
  assertEquals("Should have added the household.", hh1, hhs.getHouseholds().get(hh1.getId()));
  try{
    hhs.addHousehold(hh2);
    fail("Should not have accepted household with similar Id.");
  } catch (IllegalArgumentException e){
  }
}

org.matsim.householdsHousehold

Most used methods

  • getId
  • getMemberIds
  • getVehicleIds
  • getAttributes
  • getIncome
    This returns an Income, not a number. The Income type contains a method `getIncomePeriod()'.
  • setIncome

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • getSystemService (Context)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • String (java.lang)
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now