-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfa327a
commit 4a30958
Showing
4 changed files
with
100 additions
and
119 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
src/main/java/ldbc/finbench/datagen/generation/events/CompanyInvestEvent.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
src/main/java/ldbc/finbench/datagen/generation/events/InvestActivitesEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ldbc.finbench.datagen.generation.events; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Random; | ||
import ldbc.finbench.datagen.entities.edges.CompanyInvestCompany; | ||
import ldbc.finbench.datagen.entities.edges.PersonInvestCompany; | ||
import ldbc.finbench.datagen.entities.nodes.Company; | ||
import ldbc.finbench.datagen.entities.nodes.Person; | ||
import ldbc.finbench.datagen.generation.DatagenParams; | ||
import ldbc.finbench.datagen.util.RandomGeneratorFarm; | ||
|
||
public class InvestActivitesEvent implements Serializable { | ||
private final RandomGeneratorFarm randomFarm; | ||
|
||
public InvestActivitesEvent() { | ||
randomFarm = new RandomGeneratorFarm(); | ||
} | ||
|
||
public void resetState(int seed) { | ||
randomFarm.resetRandomGenerators(seed); | ||
} | ||
|
||
public List<Company> investPartition(List<Person> personinvestors, List<Company> companyInvestors, | ||
List<Company> targets) { | ||
Random numPersonInvestorsRand = randomFarm.get(RandomGeneratorFarm.Aspect.NUMS_PERSON_INVEST); | ||
Random choosePersonInvestorRand = randomFarm.get(RandomGeneratorFarm.Aspect.CHOOSE_PERSON_INVESTOR); | ||
Random numCompanyInvestorsRand = randomFarm.get(RandomGeneratorFarm.Aspect.NUMS_COMPANY_INVEST); | ||
Random chooseCompanyInvestorRand = randomFarm.get(RandomGeneratorFarm.Aspect.CHOOSE_COMPANY_INVESTOR); | ||
for (Company target : targets) { | ||
// Person investors | ||
int numPersonInvestors = numPersonInvestorsRand.nextInt( | ||
DatagenParams.maxInvestors - DatagenParams.minInvestors + 1 | ||
) + DatagenParams.minInvestors; | ||
for (int i = 0; i < numPersonInvestors; i++) { | ||
int index = choosePersonInvestorRand.nextInt(personinvestors.size()); | ||
Person investor = personinvestors.get(index); | ||
if (cannotInvest(investor, target)) { | ||
continue; | ||
} | ||
PersonInvestCompany.createPersonInvestCompany(randomFarm, investor, target); | ||
} | ||
|
||
// Company investors | ||
int numCompanyInvestors = numCompanyInvestorsRand.nextInt( | ||
DatagenParams.maxInvestors - DatagenParams.minInvestors + 1 | ||
) + DatagenParams.minInvestors; | ||
for (int i = 0; i < numCompanyInvestors; i++) { | ||
int index = chooseCompanyInvestorRand.nextInt(companyInvestors.size()); | ||
Company investor = companyInvestors.get(index); | ||
if (cannotInvest(investor, target)) { | ||
continue; | ||
} | ||
CompanyInvestCompany.createCompanyInvestCompany(randomFarm, investor, target); | ||
} | ||
} | ||
return targets; | ||
} | ||
|
||
public boolean cannotInvest(Person investor, Company target) { | ||
return target.hasInvestedBy(investor); | ||
} | ||
|
||
public boolean cannotInvest(Company investor, Company target) { | ||
return (investor == target) || investor.hasInvestedBy(target) || target.hasInvestedBy(investor); | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
src/main/java/ldbc/finbench/datagen/generation/events/PersonInvestEvent.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters