B u ` @sddlZddlZedZddZdZdZddZd d Z d d Z d dZ ddZ ddZ ddZddZdZdZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS))NZpyspcCs&t}||tj|dS)N)bytes)pysp_namespace_hashcopyupdateencodeuuidUUIDdigest) node_nameZnode_namespace_hashr @/tmp/pip-unpacked-wheel-n62dbgi3/pyomo/pysp/scenariotree/util.py_compute_namespacesr ilcCs|dks tt|tdS)Nr)AssertionErrorint _max_int32)xr r r _convert_range_zero_to_max_int32s rcCst|}|dkr|d7}|S)Nrr)r)rvr r r _convert_range_one_to_max_int32 srcCs|dks tt|tdS)Nrr)rr _max_uint32)rr r r !_convert_range_zero_to_max_uint32&s rcCst|}|dkr|d7}|S)Nrr)r)rrr r r _convert_range_one_to_max_uint32+srcCsttt||jS)a  Maps a PySP scenario tree variable id paired with a node name to a positive integer that can be stored in a 32-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )rruuid5r r)r vidr r r scenario_tree_id_to_pint322s rcCsttt||jS)a# Maps a PySP scenario tree variable id paired with a node name to a nonnegative integer that can be stored in a 32-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )rrrr r)r rr r r scenario_tree_id_to_nzint32?s rcCsttt||jS)a  Maps a PySP scenario tree variable id paired with a node name to a positive integer that can be stored in a 32-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )rrrr r)r rr r r scenario_tree_id_to_puint32Ls rcCsttt||jS)a# Maps a PySP scenario tree variable id paired with a node name to a nonnegative integer that can be stored in a 32-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )rrrr r)r rr r r scenario_tree_id_to_nzuint32Ys rllcCs|dks tt|tdS)Nrr)rr _max_int64)rr r r _convert_range_zero_to_max_int64ms r cCst|}|dkr|d7}|S)Nrr)r )rrr r r _convert_range_one_to_max_int64rsr!cCs|dks tt|tdS)Nrr)rr _max_uint64)rr r r !_convert_range_zero_to_max_uint64xs r#cCst|}|dkr|d7}|S)Nrr)r#)rrr r r _convert_range_one_to_max_uint64}sr$cCsttt||jS)a  Maps a PySP scenario tree variable id paired with a node name to a positive integer that can be stored in a 64-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )r!rrr r)r rr r r scenario_tree_id_to_pint64s r%cCsttt||jS)a# Maps a PySP scenario tree variable id paired with a node name to a nonnegative integer that can be stored in a 64-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )r rrr r)r rr r r scenario_tree_id_to_nzint64s r&cCsttt||jS)a  Maps a PySP scenario tree variable id paired with a node name to a positive integer that can be stored in a 64-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )r$rrr r)r rr r r scenario_tree_id_to_puint64s r'cCsttt||jS)a# Maps a PySP scenario tree variable id paired with a node name to a nonnegative integer that can be stored in a 64-bit signed integer type. The mapping is unique with high probability for a set of scenario tree ids that is not too large. (see: birthday problem) )r#rrr r)r rr r r scenario_tree_id_to_nzuint64s r()hashlibrmd5rrr rrrrrrrrrrrr"r r!r#r$r%r&r'r(r r r r  s.