<commit_before>package memap.main;

import akka.timeManagement.CurrentTimeStepSubscriber;

/**
 * Tracks the simulation progress, considering both global and
 * per building optimization
 */
public class SimulationProgress implements CurrentTimeStepSubscriber {
	private static final SimulationProgress sp = new SimulationProgress();

	/** Simulation status*/
	private Status status;
	/** Error to be printed in the gui */
	private String error;
	
	private double progress = 0;
	private final int max = (TopologyConfig.getInstance().getNrDays()
			* TopologyConfig.getInstance().getTimeStepsPerDay());

	private SimulationProgress() {
		setStatus(Status.OK, "");
	}
	
	public void restart() {
		progress = 0;
		setStatus(Status.OK, "");
	}
	
	public static SimulationProgress getInstance() {
		return sp;
	}

	public double getProgress() {
		return progress * 100 / max;
	}

	@Override
	public void update(int currentTimeStep) {
		if (currentTimeStep > progress) {
			progress = currentTimeStep;
		}
	}

	/**
	 * @return the status
	 */
	public Status getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(Status status, String error) {
		this.status = status;
		setError(error);
	}

	/**
	 * @return the error
	 */
	public String getError() {
		return error;
	}

	/**
	 * @param error the error to set
	 */
	private void setError(String error) {
		this.error = error;
	}

}
<commit_msg>Fix simulation progress algorithm<commit_after>package memap.main;

import akka.timeManagement.CurrentTimeStepSubscriber;

/**
 * Tracks the simulation progress, considering both global and per building
 * optimization
 */
public class SimulationProgress implements CurrentTimeStepSubscriber {
	private static final SimulationProgress sp = new SimulationProgress();

	/** Simulation status */
	private Status status;
	/** Error to be printed in the gui */
	private String error;

	private double progress = 0;
	private double fastProgress = 0;
	private double slowProgress = 0;
	private final int max = (TopologyConfig.getInstance().getNrDays()
			* TopologyConfig.getInstance().getTimeStepsPerDay());

	private SimulationProgress() {
		setStatus(Status.OK, "");
	}

	public void restart() {
		progress = 0;
		setStatus(Status.OK, "");
	}

	public static SimulationProgress getInstance() {
		return sp;
	}

	public double getProgress() {
		return progress * 100 / (max);
	}

	/**
	 * Update the simulation progress considering the individual progress on each
	 * simulation thread
	 */
	@Override
	public void update(int currentTimeStep) {
		// The progress of the fastest thread is stored, but it does not trigger a
		// progress update
		if (currentTimeStep > fastProgress) {
			fastProgress = currentTimeStep;
		} else if (currentTimeStep < fastProgress) { // Do nothing if ==
			// The progress off the slowest thread is stored, and the overall progress is
			// updated
			slowProgress = currentTimeStep;
			progress = (fastProgress + slowProgress) / 2;
		}
	}

	/**
	 * @return the status
	 */
	public Status getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(Status status, String error) {
		this.status = status;
		setError(error);
	}

	/**
	 * @return the error
	 */
	public String getError() {
		return error;
	}

	/**
	 * @param error the error to set
	 */
	private void setError(String error) {
		this.error = error;
	}

}

{'fraction_non_alphanumeric': 0.10335766423357665, 'fraction_numerical': 0.0037956204379562043, 'mean_word_length': 3.6931506849315068, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '1694378', 'n_tokens_mistral': 1076, 'n_tokens_neox': 976, 'n_words': 320}