<commit_before>package jUnit;

import static org.junit.Assert.*;
import generalLWRNetwork.Cell;
import generalLWRNetwork.Junction;
import generalLWRNetwork.NetworkUIDFactory;
import generalLWRNetwork.RoadChunk;
import generalNetwork.state.CellInfo;
import generalNetwork.state.JunctionInfo;
import generalNetwork.state.Profile;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.HashMap;
import java.util.LinkedHashMap;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Test2x1JunctionSolver {

  static int number_tests = 2;

  /* 2x1 junction */
  static private Junction junction2x1;
  static private Cell[] cells;

  /**
   * @brief Build a 2x1 junction
   */
  private static void build(double delta_t) {

    NetworkUIDFactory.resetCell_id();
    NetworkUIDFactory.resetJunction_id();

    // Constructing the 2x1 junction
    RoadChunk rc1 = new RoadChunk(3.0, 3.0, 3.0, delta_t);
    RoadChunk rc2 = new RoadChunk(2.0, 2.0, 2.0, delta_t);

    RoadChunk rc3 = new RoadChunk(2.5, 2.5, 2.0, delta_t);

    junction2x1 = new Junction(new Cell[] { rc1, rc2 }, new Cell[] { rc3 });
    HashMap<Integer, Double> priorities = new HashMap<Integer, Double>(2);
    priorities.put(rc1.getUniqueId(), 0.7);
    priorities.put(rc2.getUniqueId(), 0.3);
    junction2x1.setPriorities(priorities);

    cells = new Cell[3];
    cells[0] = rc1;
    cells[1] = rc2;
    cells[2] = rc3;
  }

  private static void computeDemandSupply(Profile p) {
    double density, demand, supply;
    for (int cell_id = 0; cell_id < cells.length; cell_id++) {
      density = p.get(cell_id).total_density;

      /*
       * The demand and the supply depend on the network and the density
       */
      demand = cells[cell_id].getDemand(density);
      supply = cells[cell_id].getSupply(density);
      assert demand >= 0 : "Demand should be positive";
      assert supply >= 0 : "Supply should be positive";

      p.get(cell_id).demand = demand;
      p.get(cell_id).supply = supply;

      // We clear the old flows
      p.get(cell_id).clearFlow();
    }
  }

  public static void createProfile() {
    createProfile(0.7);
    createProfile(1.0);
    createProfile(2.3);
  }

  private static void createProfile(double delta_t) {
    build(delta_t);
<commit_msg>BugFix: get has been replaced by getCell in Profile<commit_after>package jUnit;

import static org.junit.Assert.*;
import generalLWRNetwork.Cell;
import generalLWRNetwork.Junction;
import generalLWRNetwork.NetworkUIDFactory;
import generalLWRNetwork.RoadChunk;
import generalNetwork.state.CellInfo;
import generalNetwork.state.JunctionInfo;
import generalNetwork.state.Profile;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.HashMap;
import java.util.LinkedHashMap;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Test2x1JunctionSolver {

  static int number_tests = 2;

  /* 2x1 junction */
  static private Junction junction2x1;
  static private Cell[] cells;

  /**
   * @brief Build a 2x1 junction
   */
  private static void build(double delta_t) {

    NetworkUIDFactory.resetCell_id();
    NetworkUIDFactory.resetJunction_id();

    // Constructing the 2x1 junction
    RoadChunk rc1 = new RoadChunk(3.0, 3.0, 3.0, delta_t);
    RoadChunk rc2 = new RoadChunk(2.0, 2.0, 2.0, delta_t);

    RoadChunk rc3 = new RoadChunk(2.5, 2.5, 2.0, delta_t);

    junction2x1 = new Junction(new Cell[] { rc1, rc2 }, new Cell[] { rc3 });
    HashMap<Integer, Double> priorities = new HashMap<Integer, Double>(2);
    priorities.put(rc1.getUniqueId(), 0.7);
    priorities.put(rc2.getUniqueId(), 0.3);
    junction2x1.setPriorities(priorities);

    cells = new Cell[3];
    cells[0] = rc1;
    cells[1] = rc2;
    cells[2] = rc3;
  }

  private static void computeDemandSupply(Profile p) {
    double density, demand, supply;
    for (int cell_id = 0; cell_id < cells.length; cell_id++) {
      density = p.getCell(cell_id).total_density;

      /*
       * The demand and the supply depend on the network and the density
       */
      demand = cells[cell_id].getDemand(density);
      supply = cells[cell_id].getSupply(density);
      assert demand >= 0 : "Demand should be positive";
      assert supply >= 0 : "Supply should be positive";

      p.getCell(cell_id).demand = demand;
      p.getCell(cell_id).supply = supply;

      // We clear the old flows
      p.getCell(cell_id).clearFlow();
    }
  }

  public static void createProfile() {
    createProfile(0.7);
    createProfile(1.0);
    createProfile(2.3);
  }

  private static void createProfile(double delta_t) {
    build(delta_t);

{'fraction_non_alphanumeric': 0.11533767290480065, 'fraction_numerical': 0.025223759153783564, 'mean_word_length': 3.599625818521983, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6596389', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1609, 'n_words': 398}