51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
|
|
"""
|
||
|
|
Test script to verify MIP functionality
|
||
|
|
"""
|
||
|
|
|
||
|
|
import numpy as np
|
||
|
|
import pandas as pd
|
||
|
|
from mip import design_with_mip
|
||
|
|
|
||
|
|
# Create test data
|
||
|
|
np.random.seed(42)
|
||
|
|
n_turbines = 10
|
||
|
|
turbines = pd.DataFrame(
|
||
|
|
{
|
||
|
|
"x": np.random.uniform(0, 2000, n_turbines),
|
||
|
|
"y": np.random.uniform(0, 2000, n_turbines),
|
||
|
|
"power": np.random.uniform(5, 10, n_turbines),
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
substation = np.array([1000, 1000])
|
||
|
|
|
||
|
|
print("Test data created:")
|
||
|
|
print(f"Number of turbines: {n_turbines}")
|
||
|
|
print(f"Substation location: {substation}")
|
||
|
|
print(f"Total power: {turbines['power'].sum():.2f} MW")
|
||
|
|
|
||
|
|
# Test MIP function
|
||
|
|
print("\nTesting MIP design...")
|
||
|
|
try:
|
||
|
|
connections, turbines_with_clusters = design_with_mip(
|
||
|
|
turbines,
|
||
|
|
substation,
|
||
|
|
cable_specs=None,
|
||
|
|
voltage=66000,
|
||
|
|
power_factor=0.95,
|
||
|
|
system_params=None,
|
||
|
|
max_clusters=None,
|
||
|
|
time_limit=30,
|
||
|
|
evaluate_func=None,
|
||
|
|
total_invest_func=None,
|
||
|
|
get_max_capacity_func=None,
|
||
|
|
)
|
||
|
|
print(f"MIP test successful!")
|
||
|
|
print(f"Number of connections: {len(connections)}")
|
||
|
|
print(f"Clusters assigned: {turbines_with_clusters['cluster'].tolist()}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"MIP test failed with error: {e}")
|
||
|
|
import traceback
|
||
|
|
|
||
|
|
traceback.print_exc()
|