B _@sddlZddlZddlZedZddZdZdZddZ d d Z d d Z d dZ ddZ ddZddZddZdZdZddZddZddZdd 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-d4p3hk07/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_int32srcCs|dks tt|tdS)Nrr)rr _max_uint32)rr r r !_convert_range_zero_to_max_uint32s 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_pint32*s 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_nzint327s 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_puint32Ds 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_nzuint32Qs rllcCs|dks tt|tdS)Nrr)rr _max_int64)rr r r _convert_range_zero_to_max_int64es r cCst|}|dkr|d7}|S)Nrr)r )rrr r r _convert_range_one_to_max_int64jsr!cCs|dks tt|tdS)Nrr)rr _max_uint64)rr r r !_convert_range_zero_to_max_uint64ps r#cCst|}|dkr|d7}|S)Nrr)r#)rrr r r _convert_range_one_to_max_uint64usr$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_pint64|s 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()hashlibrsixmd5rrr rrrrrrrrrrrr"r r!r#r$r%r&r'r(r r r r s0