diff --git a/src/algorithms/sequential_algorithm.jl b/src/algorithms/sequential_algorithm.jl index 63f165c..e66b364 100644 --- a/src/algorithms/sequential_algorithm.jl +++ b/src/algorithms/sequential_algorithm.jl @@ -29,7 +29,6 @@ end function write_results_to_main_container(container::MultiOptimizationContainer) # TODO: This process needs to work in parallel almost right away # TODO: This doesn't handle the case where subproblems have an overlap in axis names. - for (k, subproblem) in container.subproblems for field in CONTAINER_FIELDS subproblem_data_field = getproperty(subproblem, field) @@ -42,25 +41,29 @@ function write_results_to_main_container(container::MultiOptimizationContainer) num_dims = ndims(src) num_dims > 2 && error("ndims = $(num_dims) is not supported yet") data = nothing - try - if key == ISOPT.ExpressionKey{PSI.ActivePowerBalance, PSY.ACBus}("") - @error "mt exp $k" data = PSI.jump_value.(src)[10313, :] - end - data = PSI.jump_value.(src) - catch e - if e isa UndefRefError - @error "Skip UndefRefError for" field key - continue - end - rethrow() - end + data = PSI.jump_value.(src) dst = main_container_data_field[key] if num_dims == 1 dst[1:length(axes(src)[1])] = data elseif num_dims == 2 - columns = axes(src)[1] - len = length(axes(src)[2]) +#ychen fix horizontal passing ACbusinjection issue + if field==:expressions + field1= :parameters + subproblem_data_field1 = getproperty(subproblem, field1) + src1=subproblem_data_field1[InfrastructureSystems.Optimization.ParameterKey{PowerSimulationsDecomposition.StateEstimationInjections, PSY.ACBus}("")] + B=parse.(Int,axes(src1.parameter_array)[1]) + A=axes(src)[1] + C=filter(x -> !(x in B), A) + columns= C + else + columns = axes(src)[1] + end +#ychen end + len = length(axes(src)[2]) dst[columns, 1:len] = PSI.jump_value.(src[:, :]) + #try + # println("======111 dst,k,",dst[203, :],",subproblem,",k) + #catch e end elseif num_dims == 3 # TODO: untested axis1 = axes(src)[1] @@ -86,9 +89,13 @@ function _write_parameter_results_to_main_container( src_mult_data = PSI.jump_value.(parameter_container.multiplier_array) dst_param_data = container.parameters[key].parameter_array dst_mult_data = container.parameters[key].multiplier_array + #println("*****11,subproblem,",subproblem) + #println("*****12,key,",key) + #println("*****13,num_dims,",num_dims) if num_dims == 1 dst_param_data[1:length(axes(src_param_data)[1])] = src_param_data dst_mult_data[1:length(axes(src_mult_data)[1])] = src_mult_data + elseif num_dims == 2 param_columns = axes(src_param_data)[1] mult_columns = axes(src_mult_data)[1] @@ -111,6 +118,7 @@ function solve_impl!( for (index, subproblem) in container.subproblems @debug "Solving problem $index" status = PSI.solve_impl!(subproblem, sys) + println("yc -- solving problem,",index) if status != ISSIM.RunStatus.SUCCESSFULLY_FINALIZED return status end diff --git a/src/models/network_models.jl b/src/models/network_models.jl index 2e15c45..97f6f43 100644 --- a/src/models/network_models.jl +++ b/src/models/network_models.jl @@ -283,6 +283,7 @@ function _update_parameter_values!( state = PSI.get_system_states(simulation_state) current_time = PSI.get_current_time(model) state_values = PSI.get_dataset_values(state, PSI.get_attribute_key(attributes)) + if !isfinite(first(state_values)) @warn "first value not present" state = PSI.get_decision_states(simulation_state) @@ -297,15 +298,19 @@ function _update_parameter_values!( #t_step = 1 #state_data_index = PSI.find_timestamp_index(state_timestamps, current_time) sim_timestamps = range(current_time; step=model_resolution, length=time[end]) - for state_data_index in [1] + + #ychen vertical + #for state_data_index in [1] + for state_data_index in 1:length(axes(parameter_array)[2]) #timestamp_ix = min(max_state_index, state_data_index + t_step) #@debug "parameter horizon is over the step" max_state_index > state_data_index + 1 #if state_timestamps[timestamp_ix] <= sim_timestamps[t] # state_data_index = timestamp_ix #end + #println("******** state_data_index,",state_data_index) for name_ix in component_names # Pass indices in this way since JuMP DenseAxisArray don't support view() - state_value = state_values[name_ix, state_data_index] + state_value = state_values[name_ix, state_data_index] if name_ix == "10313" @error "update pm" state_value PSI.get_attribute_key(attributes) current_time end @@ -316,7 +321,9 @@ function _update_parameter_values!( Consider reviewing your models' horizon and interval definitions", ) end - PSI._set_param_value!(parameter_array, state_value, name_ix, 1) + #ychen vertical + #PSI._set_param_value!(parameter_array, state_value, name_ix, 1) + PSI._set_param_value!(parameter_array, state_value, name_ix, state_data_index) end end return @@ -375,6 +382,7 @@ function PSI.update_container_parameter_values!( # if the keys have strings in the meta fields parameter_array = PSI.get_parameter_array(optimization_container, key) parameter_attributes = PSI.get_parameter_attributes(optimization_container, key) + #println("** tmp, disable update") _update_parameter_values!( parameter_array, parameter_attributes,