Should I repeat experiment affected by external factors until achieving consistent result I am doing an experiment assumed to be performed in ideal environment although it is not, e.g. resource is fully allocated from a resource pool shared between different organisations. As my experiment is affected by external factors (e.g. a shared pool may not fully allocate all requested resource) the result sometime is different from what I expect. However, since my model is proven to work in an ideal environment, I am sure that if I keep repeating the experiment, I will get a result which is consistent with my calculation, e.g. when a shared pool have enough resource to allocate to my request.

Notably, when I run an experiment, I do it few times to get the average result. Moreover, I'm aware that an environment is not ideal and planning to address it in my future research.

So, is it acceptable to keep repeating the experiment until I get the (average) result which is consistent with my calculation? Furthermore, should I mention in my paper how many times I perform my experiment to get the presented result or just mention briefly about the imperfect environment and a plan to handle it in future research?

Update: my research aims to use shared or volunteer resources to perform computation. It is in the early state when I calculate the required resource for a job prior to its execution. In other words, during an execution, I assume that there are enough resources for me, which doesn't always happen. As I said, I'm planning to investigate dynamic calculation in the future.
No, you shouldn't do the experiment until you get the desired result.  This is poor science and borderline unethical.  (I'm sure you had no ill intent and that you are trying to deal with real-world complications.)

An experiment is flawed if it is run n times but only the results from n - 1 are used and reported. (Or anything less than n).  See Peter Norvig's page under the section "Warning Sign I2: Ignoring Publication Bias".

Beyond this, I believe that your experimental design is flawed.  You shouldn't run an experiment assuming an ideal environment when in fact the experimental environment is not ideal.  Only in theoretical models do you have the liberty to idealize your environment.  In laboratory experiments, you control the environment so you can idealize as much as possible. What you have is an experiment with confounding factors, which is not uncommon in real-world settings.

The best thing to do is to estimate the effects of the confounding factors through analysis of a theoretical model or a simulation.  In your case, which sounds like a queuing theory problem, a statistical simulation should be relatively easy.

With this estimate, you should be able to restate your hypotheses, essentially reducing the expected effects by the "loss" associated with "the shared pool not fully allocating resources when requested".