import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
def generate_gold_concentration(size=(7, 7), seed=5555):
np.random.seed(seed)
return np.random.randint(low=0, high=10, size=size)
def analyze_drilling_results(gold_concentration, drilling_locations):
drilled_concentrations = gold_concentration[drilling_locations[:, 0], drilling_locations[:, 1]]
mean_concentration = np.mean(drilled_concentrations)
max_concentration_index = np.argmax(drilled_concentrations)
max_concentration_location = drilling_locations[max_concentration_index]
max_concentration_value = drilled_concentrations[max_concentration_index]
return drilled_concentrations, mean_concentration, max_concentration_location, max_concentration_value
def find_top_drilling_points(gold_concentration, drilling_locations, n=5):
masked_concentration = np.copy(gold_concentration)
masked_concentration[drilling_locations[:, 0], drilling_locations[:, 1]] = -1
top_indices = np.argpartition(masked_concentration.ravel(), -n)[-n:]
top_points = [(np.unravel_index(i, gold_concentration.shape), gold_concentration[np.unravel_index(i, gold_concentration.shape)]) for i in top_indices]
return sorted(top_points, key=lambda x: x[1], reverse=True)
def visualize_gold_concentration(gold_concentration, drilling_locations, max_concentration_location):
plt.figure(figsize=(10, 10))
sns.heatmap(gold_concentration, annot=True, cmap="YlOrBr", cbar=True)
for loc in drilling_locations:
plt.scatter(loc[1] + 0.5, loc[0] + 0.5, color='red', s=120, edgecolor='black', marker='o', label='Пробуренные скважины' if loc[0] == drilling_locations[0][0] else "")
plt.scatter(max_concentration_location[1] + 0.5, max_concentration_location[0] + 0.5,
color='blue', s=150, edgecolor='black', marker='*', label='Максимальная концентрация')
plt.title("Тепловая карта концентрации золота")
plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05), ncol=2)
plt.tight_layout()
plt.show()
def main():
gold_concentration = generate_gold_concentration()
drilling_locations = np.array([[0,4], [2,2], [2,3], [5,1], [6,3]])
drilled_concentrations, mean_concentration, max_concentration_location, max_concentration_value =
analyze_drilling_results(gold_concentration, drilling_locations)
top_points = find_top_drilling_points(gold_concentration, drilling_locations)
print(f"Концентрация золота в пробуренных скважинах: {drilled_concentrations}")
print(f"Средняя концентрация золота в пробуренных скважинах: {mean_concentration:.1f}")
print(f"Скважина с наивысшей концентрацией золота среди пробуренных: координаты {max_concentration_location}, концентрация — {max_concentration_value}")
print("\nСледующие 5 наилучших точек для бурения:")
for i, ((x, y), concentration) in enumerate(top_points):
print(f"{i+1}. Точка: [{x}, {y}], концентрация золота — {concentration}")
visualize_gold_concentration(gold_concentration, drilling_locations, max_concentration_location)
if __name__ == "__main__":
main()